views:

41

answers:

2

Blockquote

Hi, I have an table. I need to iterate,

for each(datarow r in datatable.rows){
  foreach(datacolumns c in datatable.columns){
     if()  // need  to  write an  condition 
      {
       // apply css
      }
     else
      {
        //no need  to apply css
      }
  }
}

I have an column as Menu_ID if MEnu_ID as an value "7" the dnt apply the css how to write an condition here.

Thank you.

+2  A: 

If I understood correctly, you need something like this:

foreach(datarow r in datatable.rows)
{
    if(((int)r["Menu_ID"])==7) {
        //Don't apply CSS
    } else {
        //Apply CSS
    }
}

this is assuming your Menu_ID column is numeric. If it is a string, change to:

if(((string)r["Menu_ID"])=="7")
Konamiman
A: 
for(int i=0; i<= datatable.rows.count-1; i++)
{
    if(datatable.Rows[i]["ColName"] == "1")
    {
     //do something
    }
    else
    {
      //do something
    }
}
Bhaskar