Devendra  Kumar

Devendra Kumar

  • NA
  • 517
  • 246.2k

gridview OnRowCommand edit update row in c#

Jan 17 2017 6:33 AM
inside grid view row command on row command edit update 
i want when edit button click then edit button hide and save button visible true
 
 
<asp:TemplateField HeaderText="Edit">
<EditItemTemplate>
<asp:LinkButton ID="save" runat="server" CommandName="save1" Text="save" CommandArgument='<%# Eval("orderId") %>'></asp:LinkButton>
</EditItemTemplate>
<ItemTemplate>
<asp:LinkButton ID="edit" runat="server" CommandName="edit1" Text="edit"></asp:LinkButton>
</ItemTemplate>
</asp:TemplateField>
 
 
and code
 
 
protected void GridClose_RowCommand(object sender, GridViewCommandEventArgs e)
{
if (e.CommandName == "edit1")
{
GridViewRow row = (GridViewRow)(((Control)e.CommandSource).NamingContainer);
TextBox txt_tracking_num = row.FindControl("txt_tracking_num") as TextBox;
DropDownList dropdwnlist = row.FindControl("dropdwnlist") as DropDownList;
LinkButton lnksave = row.FindControl("save") as LinkButton;
LinkButton edit = row.FindControl("edit") as LinkButton;
txt_tracking_num.Visible = true;
dropdwnlist.Visible = true;
lnksave.Visible = true;
}
 
 lnksave.Visible = true;
 
this is not valid show in error 

Answers (6)