[英]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.