如何使用删除按钮删除gridview中的行 [英] How to delete a row in a gridview with a delete button
问题描述
大家好
如何使用删除按钮删除网格视图中的行,并使用确认。 gridview没有数据绑定值。
值来自文本框。
i设置了删除按钮,其中包含gridview本身提供的按钮选项。
可以帮我提供代码
提前感谢
hi all
How to delete a row in a gridview with a delete button, with Confirmation. the gridview has no data bound values.
the values are from a text box.
i had set the delete button with button option provided in the gridview itself.
can any help me with the code
thanks in advance
推荐答案
你可以在Code项目中看到一个帖子,它可以让你轻松删除,只需参考这个 -
网格查看删除,确认 [ ^ ]
U can see a post in Code project itself which will let you do that deletion easily, Just refer this-
GridView Delete, with Confirmation[^]
您可以在网格视图中添加模板字段,并在其中添加一个带有命令参数属性的链接按钮并将值设置为项目ID或KeyName,然后在网格的RowCommand中,使用以下代码:
you can add a template field to your grid view and in that add a link button with command argument attribute and set the value to the item ID or KeyName, and then in RowCommand of grid, use this code:
int id = Convert.ToInt32(e.CommandArgument);
它真正依据你的数据访问逻辑来处理删除事件!
for me我使用linq到EF并只调用deleteObject方法。
确认使用onclientclick属性并使用此代码:
its realy base on your data access logic to how to handle the delete event!
for me I use linq to EF and just call the deleteObject method.
for confirmation use onclientclick attribute and use this code:
<asp:LinkButton ID="LinkButton1" OnClientClick="confirm(are you sure to delete this record"
CommandArgument='<%#Eval("id") %>' runat="server">delete</asp:LinkButton>
请参考类似的问答:
^ ]
如何从gridview中删除行。 [ ^ ]
使用复选框删除gridview中的记录 [ ^ ]
Please refer similar Q/A:
How to Delete a Row in gridview[^]
how to delete the row from gridview.[^]
delete records in gridview using checkbox[^]
这篇关于如何使用删除按钮删除gridview中的行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!