how to match database day with calendar day in asp.net -


sqlconnection con = new sqlconnection(strconnstring); con.open(); sqldataadapter sda = new sqldataadapter("select availability doc_availabledays dname='" + label2.text + "'", con); dataset dss = new dataset(); sda.fill(dss, "doc_availabledays");   datarow drr = dss.tables[0].rows[0]; drr["availability"].tostring();  if (!e.day.isothermonth) {     foreach (datarow dr in dss.tables[0].rows)     {         if ((dr["availability"].tostring().equals(dayofweek.monday))||(dr["availability"].tostring().equals(dayofweek.tuesday))||(dr["availability"].tostring().equals(dayofweek.wednesday)))         {                  e.cell.backcolor = color.palevioletred;          }     } } 

i think it's better use safe casting.

 string [] data = { "monday", "thursday", "wednesday", "tuesday" };         dayofweek d;         var dt = datetime.now;          foreach (var st in data)         {             if (enum.tryparse<dayofweek>(st, out d) && d == dt.dayofweek)             {                 string abc = "i m here";             }         } 

it looks have multiple columns in datatable dayofweek. if that's case use same condition multiple or operators || or loop datarow column well.

for further details, take @ this: c#: datetime.dayofweek string comparison


Comments

Popular posts from this blog

mysql - Dreamhost PyCharm Django Python 3 Launching a Site -

java - Sending SMS with SMSLib and Web Services -

python 3.5 - Pyqtgraph string in x tick -