62,203
社区成员
发帖
与我相关
我的任务
分享
protected void Button1_Click(object sender, EventArgs e)
{
rowChange(1);
}
/// <summary>
/// 增加或删除行
/// </summary>
/// <param name="type"></param>
public void rowChange(int type)
{
switch (type)
{
case 1:
GridView1.DataSource = CreateDataSource(GridView1.Rows.Count + 1);
GridView1.DataBind();
//BindIndex(GridView1);
break;
case 2:
GridView1.DataSource = CreateDataSource(GridView1.Rows.Count - 1);
GridView1.DataBind();
//BindIndex(GridView1);
break;
}
}
/// <summary>
/// 增加行数据源
/// </summary>
/// <param name="j"></param>
/// <returns></returns>
public ICollection CreateDataSource(int j)
{
DataTable dt = new DataTable();
DataRow dr;
for (int i = 0; i <= j - 1; i++)
{
dr = dt.NewRow();
dt.Rows.Add(dr);
}
DataView dv = new DataView(dt);
return dv;
}