I am trying to update row in GridView from database using Row Command Event, but it is not updating.
Below is GridView.
<asp:TemplateField>
<ItemTemplate>
<asp:Button ID="Btn_Close" runat="server" Text="close" CommandName="close" CommandArgument='<%# Container.DataItemIndex %>'/>
</ItemTemplate>
</asp:TemplateField>
C#
protected void GVDetail_RowCommand(object sender, GridViewCommandEventArgs e)
{
if (e.CommandName == "close")
{
// int id = Convert.ToInt32(GVDetail.DataKeys[e.RowIndex].Value);
//Determine the RowIndex of the Row whose Button was clicked.
int rowIndex = Convert.ToInt32(e.CommandArgument);
//Reference the GridView Row.
GridViewRow row = GVDetail.Rows[rowIndex];
string query = "[SP_Ret_Wiper_List]";
using (SqlCommand cmd = new SqlCommand(query))
{
cmd.Connection = con;
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.AddWithValue("@Action", "OrderDel");
cmd.Parameters.AddWithValue("@Order_ID", rowIndex);
cmd.Parameters.AddWithValue("@Del_ID", 1);
cmd.Parameters.AddWithValue("@Del_date", DateTime.Now.ToString());
con.Open();
cmd.ExecuteNonQuery();
con.Close();
Loadgrn();
}
}
}