GridView updating event does not fire!

Last post 08-29-2008 5:40 PM by Pak514. 6 replies.

Sort Posts:

  • GridView updating event does not fire!

    08-29-2008, 12:12 PM
    • Member
      16 point Member
    • captainsina
    • Member since 10-04-2006, 7:25 PM
    • Posts 43

    Hi all,

    I have a gridView that I am binding to a typed dataset that is returned from a webservice(I am not using object datasource).

    grid.datasource = dataset.datatable;

    grid.databind()

    and i am checking if it is not post back, ....

    I have added a edit,update,cancel column to my gridview. All events fire, but as soon as I change button style to Button (instead of link), only updating event does not fire(cancel event or edit event fires).

    Does anyone has any idea?!

    Cheers,

    Sina

  • Re: GridView updating event does not fire!

    08-29-2008, 12:31 PM
    • Member
      142 point Member
    • KDubAZ
    • Member since 06-20-2006, 6:00 PM
    • Posts 29

    Have you registered the event in the control?  There are a few ways to do this, the easiest is probably in markup....

    <asp:Button ID="btnExample" runat="server" Text="Example" OnClick="btnExample_OnClick" />

  • Re: GridView updating event does not fire!

    08-29-2008, 12:43 PM
    • Member
      16 point Member
    • captainsina
    • Member since 10-04-2006, 7:25 PM
    • Posts 43

    Hi,

    I am not using a template field with a button in it, I just added update,cacel,edit column type(it is a type of column u can add). In properties of that column, under appearance, u can choose button type to be link, button or image. And the only event that doesn't work is updating, cancelling works fine!

     

  • Re: GridView updating event does not fire!

    08-29-2008, 1:06 PM
    • Participant
      770 point Participant
    • Pak514
    • Member since 12-01-2007, 1:56 AM
    • Posts 300
    <asp:gridview id="asdsa" OnRowUpdating="function">
  • Re: GridView updating event does not fire!

    08-29-2008, 1:52 PM
    • Member
      16 point Member
    • captainsina
    • Member since 10-04-2006, 7:25 PM
    • Posts 43

    Here is the code I have:

     

    <asp:GridView ID="grdDays" runat="server" AutoGenerateColumns="False" CellPadding="4"
                        DataKeyNames="wkdDayId" ForeColor="#333333" GridLines="None" OnRowCancelingEdit="grdDays_RowCancelingEdit"
                        OnRowEditing="grdDays_RowEditing" OnRowUpdating="grdDays_RowUpdating" Width="100%">
                        <RowStyle BackColor="#EFF3FB" />
                        <Columns>
                            <asp:BoundField DataField="wkdTitle" HeaderText="Day" ReadOnly="True" />
                            <asp:BoundField DataField="wkdStartTime" HeaderText="Start" />
                            <asp:BoundField DataField="wkdFinishTime" HeaderText="Finish" />
                            <asp:CommandField ShowEditButton="True" ButtonType="Button" />
                        </Columns>
                        <FooterStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
                        <PagerStyle BackColor="#2461BF" ForeColor="White" HorizontalAlign="Center" />
                        <SelectedRowStyle BackColor="#D1DDF1" Font-Bold="True" ForeColor="#333333" />
                        <HeaderStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
                        <EditRowStyle BackColor="#2461BF" />
                        <AlternatingRowStyle BackColor="White" />
                    </asp:GridView>

    And in code behind i have:

            protected void grdTest_RowEditing(object sender, GridViewEditEventArgs e)
            {
                int a = 1;
                this.grdDays.EditIndex = e.NewEditIndex;
                this.grdDays.DataBind();
            }

            protected void grdTest_RowUpdating(object sender, GridViewUpdateEventArgs e)
            {
                int a = 1;
            }

            protected void grdTest_RowCancelingEdit(object sender, GridViewCancelEditEventArgs e)
            {
                int a = 1;
            }
     and all get invoked except grdTest_RowUpdating.
    Thanks

  • Re: GridView updating event does not fire!

    08-29-2008, 4:03 PM
    Answer
    • Member
      142 point Member
    • KDubAZ
    • Member since 06-20-2006, 6:00 PM
    • Posts 29

    The first thing I notice is the in your markup the prefix for each handler is grdDays while in your codebehind the prefix is grdTest for each of the methods... I copied and pasted your code and changed the prefixes to match and everything works as expected for me.

  • Re: GridView updating event does not fire!

    08-29-2008, 5:40 PM
    • Participant
      770 point Participant
    • Pak514
    • Member since 12-01-2007, 1:56 AM
    • Posts 300

    You try restarting the IDE yet? This usually solves the problem when this happens to me.

Page 1 of 1 (7 items)