Able Traversal method Method 1: datatable dt = dataset. tables [0]; for (INT I = 0; I <DT. rows. count; I ++) {string strname = DT. rows [I] ["field name"]. tostring ();} Method 2: foreach (datarow myrow in mydataset. tables ["Temp"]. rows) {var STR = myrow [0]. tostring ();} method 3: foeach (datarow DR in DT. rows) {object value = Dr ["columnsname"];} Method 4: able dt = new datatable (); foreach (datarow DR in DT. rows) {(INT I = 0; I <DT. Columns. Count; I ++) {Dr [I] ;}} binds the datatable to reapter. If (dtb_xx.rows.count> 0) {rp_xx.datasource = dtb_xx; rp_xx.databind () ;}< ASP: repeater id = "rp_xx" runat = "server"> <itemtemplate> <tr> <TD> <div> <ul class = "listhorizontally"> <li> <Div class =" tcell1 "> <% # eval (" ID ") %> </div> </LI> <li> <Div class = "tcell2"> <% # eval ("name ") %> </div> </LI> </ul> </div> </TD> </tr> </itemtemplate> </ASP: repeater> Method 5 datarow [] datarows = NULL; datarows = able. sel ECT (fieldparentid + "= '" + treenode. tag. tostring () + "'", datatable. defaultview. sort); foreach (datarow in datarows) {datarow = datatable. rows [I];? = Datarow [fieldparentid]. tostring ();}
Several Methods for Traversing datatable [reprinted]