1

Is it possible to populate asp.net GridView with data and operate on those data without dataBinding, as it is possible with Winforms DataGridView?

1 Answer 1

2

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();
Sign up to request clarification or add additional context in comments.

5 Comments

Isn't this databinding? this.GridView1.DataSource = ((DataTable)Session["myDatatable"]).DefaultView; this.GridView1.DataBind();
This is also databinding. Me.GridView1.DataSource = userinfos Me.GridView1.DataBind()
All unbound means to me is that the grid is not operating against a DB for me (insert, update, delete,etc).. I control that not the grid. In the above scenario's I control the grid which is the same in the winforms world to me....
links have broke
@user7733611 Updated answer without links. :-)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.