Is it possible to programmatically add a row to a GridView in C# ASP?
If yes, how ?
I want to add static data directly from the code, not from an array nor an datasource
DataTable dt = new DataTable();
DataRow dr = dt.NewRow();
dr["Column1"] = string.Empty;
dt.Rows.Add(dr);
You can then bind your GridView
to the DataTable
...
gv.DataSource = dt;
gv.DataBind();
dataGridView1.Columns[0].Name = "column1";
dataGridView1.Columns[1].Name = "column2";
string[] row1 = new string[] { "column1 value", "column2 value" };
dataGridView1.Rows.Add(row1);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With