ASP.Net GridView edit button not working: GridView not going in Edit mode

Last Reply on May 14, 2014 01:19 AM By Mudassar

Posted on May 13, 2014 12:14 PM

in .aspx page

<asp:GridView ID="gvErection" runat="server" AutoGenerateColumns="false" 
onrowcancelingedit="gvErection_RowCancelingEdit" 
onrowediting="gvErection_RowEditing" onrowupdating="gvErection_RowUpdating">
<Columns> 

<asp:TemplateField>
<ItemTemplate>
<asp:LinkButton ID="lnkEdit" runat="server" Text="Edit"

CommandName="Edit"></asp:LinkButton>
</ItemTemplate>
<EditItemTemplate>
<asp:LinkButton ID="lnkUpdate" runat="server" Text="Update"

CommandName="Update"></asp:LinkButton>&nbsp;
<asp:LinkButton ID="lnkCancel" runat="server" Text="Cancel"

CommandName="Cancel"></asp:LinkButton>
</EditItemTemplate>
</asp:TemplateField>

<asp:TemplateField HeaderText="Item Number">
<ItemTemplate>
<asp:Label ID="lblITEM_ID" runat="server" Text='<%# Eval("ITEM_ID")

%>'></asp:Label>
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox ID="lblITEM_ID11" runat="server" Text='<%# Eval("ITEM_ID")

%>'></asp:TextBox> </EditItemTemplate> </asp:TemplateField></Columns></asp:GridView>

in .aspx.cs

protected void gvErection_RowCancelingEdit(object sender, GridViewCancelEditEventArgs e)
{
gvErection.EditIndex = -1;
}
protected void gvErection_RowEditing(object sender, GridViewEditEventArgs e)
{
gvErection.EditIndex = e.NewEditIndex;
}

when i m clicking edit button one time ,it is not going in edit mode.

it is going in edit mode when i m clicking second time on edit button.

Posted on May 14, 2014 01:19 AM

Bind GridView in !IsPostBack condition in Page Load event

I agree, here is the link: https://www.e-iceblue.com/Introduce/spire-office-for-net-free.html