Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Building Controls > GridView.RowUpdated not firing

Reply
Thread Tools

GridView.RowUpdated not firing

 
 
TS
Guest
Posts: n/a
 
      02-19-2009
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?


 
Reply With Quote
 
 
 
 
Allen Chen [MSFT]
Guest
Posts: n/a
 
      02-20-2009
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/subs...#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/subs.../aa948874.aspx
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.

 
Reply With Quote
 
 
 
 
Allen Chen [MSFT]
Guest
Posts: n/a
 
      02-26-2009
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

 
Reply With Quote
 
TS
Guest
Posts: n/a
 
      03-06-2009
yes, i sent it on march 3rd.


"Allen Chen [MSFT]" <v-> 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
>



 
Reply With Quote
 
Allen Chen [MSFT]
Guest
Posts: n/a
 
      03-09-2009
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.HandleUpdateC allback));
//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

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
master page does not change due to preinit event not firing franchise63 General Computer Support 0 02-13-2008 09:18 AM
DataGrid ItemCommand event not firing if not first page =?Utf-8?B?ZGFuYw==?= ASP .Net 3 10-26-2005 05:24 PM
DataGris Paging not working (event not firing) Ryan Rueckl ASP .Net Datagrid Control 8 06-24-2005 07:13 PM
Control not maintaing viewState and PostBack not firing event. Don ASP .Net Building Controls 1 05-16-2005 01:45 PM
Re: onkeypress not being recognized, or not firing S. Justin Gengo ASP .Net 0 08-26-2003 04:15 PM



Advertisments