对GridView增加空白行
存在数据源的时候,就需要用到DataTable
1
2
3
4
5
6
7
8
9
10
11
DataTable dt = this.GridView1.DataSource as DataTable;
DataRow dr = dt.NewRow();
//也就是说存在数据源时候需要是同DataTable获取当前的绑定数据,然后DataTable新增一行空值的行再次绑定就OK
//不存在数据源也可以这么做
//或者这个
protected void Button1_Click(object sender, EventArgs e)
{
this.SqlDataSource1.Insert();
this.GridView1.DataBind();
}