Reputation: 17026
Is it possible to populate asp.net GridView with data and operate on those data without dataBinding, as it is possible with Winforms DataGridView?
Upvotes: 1
Views: 2961
Reputation: 21098
You can set the data source to a datatable that you can build up in code with whatever you like.
var table = new DataTable();
table.Columns.Add("Column1");
table.Columns.Add("Column2");
var row = table.NewRow();
row["Column1"] = "test";
row["Column2"] = "test2";
table.Rows.Add(row);
GridView.DataSource = table;
GridView.DataBind();
You can also set a gridview's data source with a list:
var yourList = new List<YourRowStuff>();
get the list from a database query or build it up manually in code....
GridView.DataSource = yourList;
GridView.DataBind();
Upvotes: 2