GridView.RowUpdated not firing

Discussion in 'ASP .Net Building Controls' started by TS, Feb 19, 2009.

  1. TS

    TS Guest

    this is a continuation from "overriding GridView.OnRowDeleting - can call
    registered event handlers" I couldnt figure out how to continue this thread,
    but the issues in it are related so i'm including it as a reference.

    In my custom gridView control I cannot raise the RowUpdated event. I have
    tried to add an event handler to the RowUpdated event of my custom control
    but it is not called. I have tried to override OnRowUpdated in my custom
    control, but the breakpoint never gets hit. I have tried to not override in
    control and instead use delegates like I described in previous post, but the
    event never fires in control or aspx page.

    What is going wrong?
    TS, Feb 19, 2009
    1. Advertisements

  2. Hi TS,

    I reviewed your previous case. This behavior looks really strange. Firstly
    could you test if RowUpdating fires? If it does most likely the updating is
    cancelled in a phase between RowUpdating and RowUpdated. For example, if
    you add following line in RowUpdating event handler the RowUpdated event
    will not get triggered.

    protected void GridView1_RowUpdating(object sender, GridViewUpdateEventArgs
    e.Cancel = true;

    If there's no such code another possible reason I could think of is
    probably the custom GridView is bound on every postback, like below:

    protected void Page_Load(object sender, EventArgs e)

    It may cause the update not working and the state of the GridView will not
    shift back to readonly mode after Update button is clicked.

    If none of the above information can help to solve this problem I think I
    need some repro code to do further troubleshooting. Could you send me a
    demo that can reproduce this problem? My email is
    update here after sending the project in case I
    missed that email.

    Allen Chen
    Microsoft Online Support

    Delighting our customers is our #1 priority. We welcome your comments and
    suggestions about how we can improve the support we provide to you. Please
    feel free to let my manager know what you think of the level of service
    provided. You can send feedback directly to my manager at:

    Get notification to my posts through email? Please refer to

    Note: MSDN Managed Newsgroup support offering is for non-urgent issues
    where an initial response from the community or a Microsoft Support
    Engineer within 2 business day is acceptable. Please note that each follow
    up response may take approximately 2 business days as the support
    professional working with you may need further investigation to reach the
    most efficient resolution. The offering is not appropriate for situations
    that require urgent, real-time or phone-based interactions. Issues of this
    nature are best handled working with a dedicated Microsoft Support Engineer
    by contacting Microsoft Customer Support Services (CSS) at
    This posting is provided "AS IS" with no warranties, and confers no rights.
    Allen Chen [MSFT], Feb 20, 2009
    1. Advertisements

  3. Hi TS,

    Have you sent me the project? Please update here after sending it in case I
    missed that email.

    Allen Chen
    Microsoft Online Community Support
    Allen Chen [MSFT], Feb 26, 2009
  4. TS

    TS Guest

    yes, i sent it on march 3rd.
    TS, Mar 6, 2009
  5. Hi TS,

    Thanks. I checked my inbox and found that email. Sorry that I didn't see
    that email before.

    I've debugged your code. I think the problem is, the gvCensus is bound in
    an too early stage so even the RowUpdating doesn't fire. You can edit
    Default.aspx.cs like below:

    protected override void OnInit(EventArgs e)

    gvCensus.RowEditing += new GridViewEditEventHandler(gvCensus_RowEditing);
    gvCensus.RowUpdating += new
    gvCensus.RowDataBound += new
    gvCensus.RowCreated += new GridViewRowEventHandler(gvCensus_RowCreated);
    gvCensus.DataBound += new EventHandler(gvCensus_DataBound);
    gvCensus.RowUpdated += new

    protected override void OnLoad(EventArgs e)

    Then the RowUpdating will fire.

    Another important thing is, the RowUpdated event will not fire if the
    update is cancelled in RowUpdating or no DataSourceID is specified. See the
    source code of GridView:

    this.OnRowUpdating(e); //Fire RowUpdating
    if (!e.Cancel && isBoundUsingDataSourceID)
    this._updateKeys = e.Keys;
    this._updateOldValues = e.OldValues;
    this._updateNewValues = e.NewValues;
    data.Update(e.Keys, e.NewValues, e.OldValues, new
    //RowUpdated fires in the call back

    So if you want your control user get notified after updated you can expose
    a new event, overwrite OnRowUpdating and fire that event after successfully

    Please try it to see if it works. BTW, if you don't receive my reply within
    48 hours please update in the newsgroup. I'll check each case I take
    everyday but email is likely to be missed. Sorry again for the
    inconvenience brought to you and please feel free to let me know if you
    need additional assistance.

    Allen Chen
    Microsoft Online Support
    Allen Chen [MSFT], Mar 9, 2009
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.