How to retrieve data from Database by ( List<> ) instead of data table?
How can I do this?
How to retrieve data from Database by ( List<> ) instead of data table?
How can I do this?
Follow these steps
display your data
public class myListClass { public string myListClassItem1{ set; get; } public string myListClassItem2{ set; get; } public string myListClassItem3{ set; get; } }
List items = new List();
while (reader.Read()) { items.Add(new myListClass(reader["Item1"].ToString(), reader["Item2"].ToString(), reader["Item3"].ToString())); }
myDataGrid.DataSource = items;
myDataGrid.DataBind();