FineUI 官方论坛
标题:
利用实体类 实现 grid 动态 增加 删除行
[打印本页]
作者:
£快乐→无罪
时间:
2012-5-9 09:17
标题:
利用实体类 实现 grid 动态 增加 删除行
后台代码:
//增加子项
protected void cid_Click(object sender, EventArgs e)
{
List<modelbas_partkind> theba = new List<modelbas_partkind>();
for (int i = 0; i < product.Rows.Count; i++)
{
modelbas_partkind mo = new modelbas_partkind();
GridRow rows = product.Rows[i];
System.Web.UI.WebControls.TextBox tx = (System.Web.UI.WebControls.TextBox)rows.FindControl("TextBox5");
mo.Kind_code = tx.Text;
theba.Add(mo);
}
modelbas_partkind mo1 = new modelbas_partkind();
theba.Add(mo1);
product.DataSource = theba;
product.DataBind();
}
#region 删除子项
protected void product_RowCommand(object sender, ExtAspNet.GridCommandEventArgs e)
{
if (e.CommandName == "delete" )
{
List<modelbas_partkind> theba = new List<modelbas_partkind>();
for (int i = 0; i < product.Rows.Count; i++)
{
if (i != e.RowIndex)
{
modelbas_partkind mo = new modelbas_partkind();
GridRow rows = product.Rows[i];
System.Web.UI.WebControls.TextBox tx = (System.Web.UI.WebControls.TextBox)rows.FindControl("TextBox5");
mo.Kind_code = tx.Text;
theba.Add(mo);
}
}
product.DataSource = theba;
product.DataBind();
}
}
#endregion
作者:
swtseaman
时间:
2012-5-9 12:32
顶个好方法!
欢迎光临 FineUI 官方论坛 (https://fineui.com/bbs/)
Powered by Discuz! X3.4