for (int i = 0; i < dataTable.Rows.Count; i++) { for (int j = 0; j < dataTable.Columns.Count; j++) { Console.WriteLine(dataTable.Rows[i][j].ToString()); } } 方法1: for (int i = 0; i < dt.Rows.Count; i++) { Response.Write(dt.Rows[i]["kjnybh"].ToString());//行集合.行【号】列【名】 } 方法2 : foreach (DataRow dr2 in dt.Rows) { Response.Write(dr2["kjny"].ToString() ); }
转 : https://www.cnblogs.com/sdpdf/p/4322500.html