[英]How to Delete /Edit a row in GridView dynamically with Buttons present in grid itself
How to Delete / Edit a row in GridView
dynamically with Buttons
present in GridView
itself 如何使用GridView
本身中的Buttons
动态删除/编辑GridView
的行
I have tried RowDeleting
event for deleting & RowEditing
for Edit.But, I can't get the desired result 我已经尝试使用RowDeleting
事件来删除& RowEditing
for Edit.But,我无法获得所需的结果
Using VS2005 asp.net C# 2.0 使用VS2005 asp.net C#2.0
below is what I tried in RowDeleting
event 下面是我在RowDeleting
事件中尝试过的
protected void GridViewFRM_RowDeleting(object sender, GridViewDeleteEventArgs e)
{
if (connection.State == ConnectionState.Closed)
{
connection.Open();
}
OracleCommand OLCOM3 = new OracleCommand();
OLCOM3.CommandText = "Delete from FORUM WHERE QUESTION='" + GridViewFRM.DataKeys[e.RowIndex].Values[0].ToString() + "'";
OLCOM3.ExecuteNonQuery();
DisplayUserData();
}
Give command name to edit and delete button 给命令名称编辑和删除按钮
<asp:ImageButton runat="server" id="editBtn" commandName="Edit"></asp:ImageButton>
Same for Delete 删除相同
You can follow this http://www.codeproject.com/Tips/564619/Example-of-gridview-rowcommand-on-Button-Click 你可以按照这个http://www.codeproject.com/Tips/564619/Example-of-gridview-rowcommand-on-Button-Click
Change the command name according to your convince. 根据你的说服改变命令名称。 but do not use "delete/edit" because we are using row command not edit /delete command. 但不要使用“删除/编辑”,因为我们使用的是row命令而不是编辑/删除命令。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.