如何在asp.net的GridView实现编辑,我是手写的,不是自动生成的,还有我选中了多行数据,怎么取得他们的ID?
1个回答
展开全部
编辑事件:
protected void gvdata_RowEditing(object sender, GridViewEditEventArgs e)
{
this.gvdata.EditIndex =e.NewEditIndex;
bindata();
}
取消编辑:
protected void gvdata_RowCancelingEdit(object sender, GridViewCancelEditEventArgs e)
{
this.gvdata.EditIndex = -1;
bindata();
}
//编辑
protected void gvOrgan_RowUpdating(object sender, GridViewUpdateEventArgs e)
{
string sql="update";
//方法;
}
主键:id绑定
<asp:TemplateField SortExpression="td" HeaderText="类型编号">
<ItemTemplate>
<asp:Label ID="lblTd" runat="server" Text='<%#Eval("td") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
protected void gvdata_RowEditing(object sender, GridViewEditEventArgs e)
{
this.gvdata.EditIndex =e.NewEditIndex;
bindata();
}
取消编辑:
protected void gvdata_RowCancelingEdit(object sender, GridViewCancelEditEventArgs e)
{
this.gvdata.EditIndex = -1;
bindata();
}
//编辑
protected void gvOrgan_RowUpdating(object sender, GridViewUpdateEventArgs e)
{
string sql="update";
//方法;
}
主键:id绑定
<asp:TemplateField SortExpression="td" HeaderText="类型编号">
<ItemTemplate>
<asp:Label ID="lblTd" runat="server" Text='<%#Eval("td") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询