[英]How to Delete /Edit a row in GridView dynamically with Buttons present in grid itself
如何使用GridView
本身中的Buttons
动态删除/编辑GridView
的行
我已经尝试使用RowDeleting
事件来删除& RowEditing
for Edit.But,我无法获得所需的结果
使用VS2005 asp.net C#2.0
下面是我在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();
}
给命令名称编辑和删除按钮
<asp:ImageButton runat="server" id="editBtn" commandName="Edit"></asp:ImageButton>
删除相同
你可以按照这个http://www.codeproject.com/Tips/564619/Example-of-gridview-rowcommand-on-Button-Click
根据你的说服改变命令名称。 但不要使用“删除/编辑”,因为我们使用的是row命令而不是编辑/删除命令。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.