How to Delete / Edit a row in GridView
dynamically with Buttons
present in GridView
itself
I have tried RowDeleting
event for deleting & RowEditing
for Edit.But, I can't get the desired result
Using VS2005 asp.net C# 2.0
below is what I tried in RowDeleting
event
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
Change the command name according to your convince. but do not use "delete/edit" because we are using row command not edit /delete command.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.