遍历datatable的几种方法(C# )
来源:互联网 发布:traceroute windows 编辑:程序博客网 时间:2024/05/21 00:20
转载
- 遍历datatable的方法2009-09-08 10:02方法一:
- DataTable dt = dataSet.Tables[0];
- for(int i = 0 ; i < dt.Rows.Count ; i++)
- {
- string strName = dt.Rows[i]["字段名"].ToString();
- }
- 方法二:
- foreach(DataRow myRow in myDataSet.Tables["temp"].Rows)
- {
- var str = myRow[0].ToString();
- }
- 方法三:
- foeach(DataRow dr in dt.Rows)
- {
- object value = dr["ColumnsName"];
- }
- 方法四:
- DataTable dt=new DataTable();
- foreach(DataRow dr in dt.Rows)
- {
- for(int i=0;i<dt.Columns.Count;i++)
- {
- dr[i];
- }
- }
- 绑定DataTable到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>
- 方法五
- DataRow[] dataRows = null;
- dataRows = dataTable.Select(fieldParentID + "='" + treeNode.Tag.ToString() + "'", dataTable.DefaultView.Sort);
- foreach (DataRow dataRow in dataRows)
- {
- DataRow dataRow = dataTable.Rows[i];
- ?? = dataRow[fieldParentID].ToString();
- }
0 0
- 遍历datatable的几种方法(C# )
- 遍历datatable的几种方法
- C# Dictionary 的几种遍历方法
- C# Dictionary 的几种遍历方法
- C# Dictionary 的几种遍历方法
- C# Dictionary 的几种遍历方法
- C# Dictionary 的几种遍历方法
- c#遍历dictionary的几种方法
- C# Dictionary 的几种遍历方法
- C# Dictionary 的几种遍历方法
- C# Dictionary 的几种遍历方法
- C# Dictionary 的几种遍历方法
- C# Dictionary 的几种遍历方法
- C# Dictionary 的几种遍历方法
- C# Dictionary 的几种遍历方法
- 遍历DataTable的几种方式
- 遍历datatable的方法
- 遍历datatable的方法
- SVG 形状元素(rect、circle、ellipse、line、polyline、polygon、path)
- 总结ThinkPHP导出数据到表格的几种方法及代码,分享给大家,注释超详细。
- /dev/shm不足导致执行root.sh报错Died at /u01/app/11.2.0/grid/crs/install/crsinstall.pm
- 解决zebra下ospf正常启动却无法建立邻居的问题
- nginx location笔记
- 遍历datatable的几种方法(C# )
- EL表达式
- Android中为什么主线程不会因为Looper.loop()方法造成阻塞
- 简单集成融云(一)
- 深入分析Struts2工作流程
- Java Classloader机制解析
- 使用最新的iOS9 开始推荐使用的<Photos/Photos.h>这个框架实现保存图片或者视频
- 在web.xml中配置文件路径classpath
- 活动安排问题-2 (51nod)