在gridview中删除记录 [英] deleting records in gridview
本文介绍了在gridview中删除记录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
当使用gridview中的复选框选中特定行时,如何从gridview中删除记录?
how to delete a record from gridview when particular row has been checked using checkbox in that gridview?
推荐答案
您可以简单地使用GridView RowCommand和CommandArgument .
像这样尝试,
You can simply use GridView RowCommand and CommandArgument for the same.
Try out like this,
<asp:templatefield xmlns:asp="#unknown">
<headertemplate>
Delete
</headertemplate>
<itemtemplate>
<asp:imagebutton commandname="DeleteCommand" commandargument="<%# Eval(" id=" )%>" imageurl="/test.pmg">
ID="lnk" runat="server" />
</asp:imagebutton></itemtemplate>
</asp:templatefield>
并在代码背后
and in codebehind
Protected Void Grid_RowCommand(object sender, GridViewEventArgs e)
{
if(e.CommandName=="DeleteCommand")
{
CheckBox cb= (CheckBox)e.Row.findControl("chkbox");
if(cb.Checked)
{
DeletedRecord(e.CommandArgument);
}
}
}
请检查语法.
Please check for the syntax.
请尝试以下操作:
删除多行记录Gridview复选框确认
Try the following:
Delete Multiple Rows Records Gridview CheckBox Confirmation
这篇关于在gridview中删除记录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文