Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Loop through the rows of a particular DataTable

IDE : VS 2008, Platform : .NET 3.5,

Hi,

Here is my DataTable columns :

ID Note Detail

I want to write sth like this :

//below code block is not the right syntax   For each q in dtDataTable.Column("Detail")      strDetail = Row of Column Detail   Next 

Can anyone give me a suggestion and show me a code sample please ? Thanks.

like image 863
Tola Avatar asked Mar 05 '09 04:03

Tola


1 Answers

For Each row As DataRow In dtDataTable.Rows     strDetail = row.Item("Detail") Next row 

There's also a shorthand:

For Each row As DataRow In dtDataTable.Rows     strDetail = row("Detail") Next row 

Note that Microsoft's style guidelines for .Net now specifically recommend against using hungarian type prefixes for variables. Instead of "strDetail", for example, you should just use "Detail".

like image 71
Joel Coehoorn Avatar answered Sep 18 '22 17:09

Joel Coehoorn