How to iterate through a DataTable

后端 未结 4 1448
死守一世寂寞
死守一世寂寞 2020-11-29 19:51

I need to iterate through a DataTable. I have an column there named ImagePath.

When I am using DataReader I do it this way:

4条回答
  •  余生分开走
    2020-11-29 20:24

    You can also use linq extensions for DataSets:

    var imagePaths = dt.AsEnumerble().Select(r => r.Field("ImagePath");
    foreach(string imgPath in imagePaths)
    {
        TextBox1.Text = imgPath;
    }
    

提交回复
热议问题