如何从某个索引中删除datarow单元格?

时间:2015-10-21 08:37:09

标签: c#

我需要从满足先前条件的某个单元格索引清空datarow。

if (tabControl1.SelectedIndex == 1)
{
    for (int i = 0; i < dtSecondTab.Rows.Count; i++)
    {
         if (dtSecondTab.Rows[i]["Month"].ToString() != "" && dtSecondTab.Rows[i]["Month"].ToString() != Convert.ToInt32(cbMonth.Text).ToString())
         {
             //here I need to clear datarow from cell index 6 to the end of the row                      
         }
    }
}

1 个答案:

答案 0 :(得分:0)

for(int cellIndex = 6; cellIndex < dtSecondTab.Columns.Count; cellIndex++)
{
    dtSecondTab.Rows[i][cellIndex] =  DBNull.Value;
}