How to get the row number from a datatable?

前端 未结 7 1423
谎友^
谎友^ 2020-12-08 06:18

I am looping through every row in a datatable:

foreach (DataRow row in dt.Rows) {}

I would like to get the index of the current row within

7条回答
  •  失恋的感觉
    2020-12-08 06:53

    ArrayList check = new ArrayList();            
    
    for (int i = 0; i < oDS.Tables[0].Rows.Count; i++)
    {
        int iValue = Convert.ToInt32(oDS.Tables[0].Rows[i][3].ToString());
        check.Add(iValue);
    
    }
    

提交回复
热议问题