Jump to content

ASP.Net - GridView


Recommended Posts

I am using C# 3.0, and ASP.Net 2.0I have a GridView control, and I want to control the placement of the Edit/Update/Cancel buttons.I have set the AutoEventWireup property to false for the page.I then set the AutoGenerateEditButton property to false for my grid, and add a template column as this:

           <asp:TemplateField>                <ItemTemplate>                    <asp:LinkButton ID="LinkButton1" runat="server" CausesValidation="false" CommandName="Edit" Text="Edit"></asp:LinkButton>                </ItemTemplate>                <EditItemTemplate>                    <asp:LinkButton ID="LinkButton2" runat="server" CommandName="Update" Text="Update"></asp:LinkButton>                    <asp:LinkButton ID="LinkButton3" runat="server" CausesValidation="false" CommandName="Cancel" Text="Cancel"></asp:LinkButton>                </EditItemTemplate>            </asp:TemplateField>

I then add my event Handlers in the OnInit function in the code behind:

   override protected void OnInit(EventArgs e)    {        this.DataBinding += new System.EventHandler(this.Detail_DataBinding);        this.dtlGrid.RowEditing += new GridViewEditEventHandler(dtlGrid_RowEditing);        this.dtlGrid.RowCancelingEdit += new GridViewCancelEditEventHandler(dtlGrid_RowCancelingEdit);        this.dtlGrid.RowUpdating += new GridViewUpdateEventHandler(dtlGrid_RowUpdating);        this.dtlGrid.RowUpdated += new GridViewUpdatedEventHandler(dtlGrid_RowUpdated);        base.OnInit(e);    }

When I click the Edit button, I do throw the RowEditing event, but the Cancel/Update events don't happen.I have also tried the same setup with the page property AutoEventWireup set to True.Does anybody have an idea why my events are not firing?Thank you, Bryan

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Create New...