如何在数据列表控件中的grdview中动态添加gridview

问题描述:

亲爱的,
我使用了一个数据列表控件,在其中添加了具有三列的gridview模板.
在数据列表中,有两行表示两个网格视图.

现在我想在第一行的gridview中动态添加行.

我该怎么做

谢谢您,

Dear,
I used a datalist control in which i added a gridview template with three columns.
In datalist 2 rows are there that means two gridviews.

Now i want to add rows dynamically in gridview of first row.

How can i do this

Thank you,

DataTable dt = new DataTable();
//this is used to add columns in the database, means columns in your GridView
dt.Columns.Add(new DataColumn("column_name", typeof(string)));
//this is used to initialise datarow
DataRow Dr = dt.NewRow();
//specify column value
Dr["column_name"] = "column_value";
//now you are adding a row in the datatable along with value(s) you specified.
dt.Rows.Add(Dr);
GridView1.DataSource = dt;
GridView1.DataBind();