Get data from datatable into a string in asp.net
I use a SQL query and store the result into a datatable and now I want to write a specific cell data in to a string or char.
Below is the code I want to get the data from row[0]
column[1]
da = new SqlDataAdapter(&开发者_如何学Goquot;SELECT * FROM SeatsDetails WHERE ServiceNo='"+srno+"' AND Date='"+date+"'", con);
dt = new DataTable();
da.Fill(dt);
String t1 = (String) dt.Rows[0][1];
I had got it using, Thanks fo the effort.
String t1 = dt.Rows[0][1].ToString();
Using LinQ queries in c# is also a good option to fetch all the results:
List<string> DataList2 = dt.AsEnumerable().Select(row => row.Field<string>("value")).ToList();
精彩评论