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
    1. Advertising

  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)
    {
    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)
    {
    this.GridView1.DataBind();
    }

    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.

    Regards,
    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
    http://msdn.microsoft.com/en-us/subscriptions/aa948868.aspx#notifications.

    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
    http://msdn.microsoft.com/en-us/subscriptions/aa948874.aspx
    ==================================================
    This posting is provided "AS IS" with no warranties, and confers no rights.
     
    Allen Chen [MSFT], Feb 20, 2009
    #2
    1. Advertising

  3. Hi TS,

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

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

    TS Guest

    yes, i sent it on march 3rd.


    "Allen Chen [MSFT]" <> wrote in message
    news:Rsiebj%...
    > Hi TS,
    >
    > Have you sent me the project? Please update here after sending it in case
    > I
    > missed that email.
    >
    > Regards,
    > Allen Chen
    > Microsoft Online Community Support
    >
     
    TS, Mar 6, 2009
    #4
  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
    GridViewUpdateEventHandler(gvCensus_RowUpdating);
    gvCensus.RowDataBound += new
    GridViewRowEventHandler(gvCensus_RowDataBound);
    gvCensus.RowCreated += new GridViewRowEventHandler(gvCensus_RowCreated);
    gvCensus.DataBound += new EventHandler(gvCensus_DataBound);
    gvCensus.RowUpdated += new
    GridViewUpdatedEventHandler(gvCensus_RowUpdated);
    }

    protected override void OnLoad(EventArgs e)
    {
    gvCensus.DataBind();
    base.OnLoad(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
    DataSourceViewOperationCallback(this.HandleUpdateCallback));
    //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
    updated.

    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.


    Regards,
    Allen Chen
    Microsoft Online Support
     
    Allen Chen [MSFT], Mar 9, 2009
    #5
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Alex A.

    Gridview RowUpdating is not firing

    Alex A., Jan 31, 2006, in forum: ASP .Net
    Replies:
    2
    Views:
    3,278
    sojae
    May 15, 2007
  2. Kevin Attard

    GridView RowCommand event not firing!!

    Kevin Attard, Aug 8, 2006, in forum: ASP .Net
    Replies:
    8
    Views:
    31,802
    Lawrence Mucheka
    May 29, 2008
  3. bill
    Replies:
    2
    Views:
    3,151
    Usmanr
    Jun 16, 2008
  4. AG
    Replies:
    14
    Views:
    12,352
    jbarnett74
    Aug 25, 2010
  5. =?Utf-8?B?c2xlbWVu?=

    GridView RowUpdated Never Fires

    =?Utf-8?B?c2xlbWVu?=, Nov 2, 2006, in forum: ASP .Net
    Replies:
    0
    Views:
    563
    =?Utf-8?B?c2xlbWVu?=
    Nov 2, 2006
Loading...

Share This Page