Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   ASP .Net Building Controls (http://www.velocityreviews.com/forums/f59-asp-net-building-controls.html)
-   -   GridView.RowUpdated not firing (http://www.velocityreviews.com/forums/t759056-gridview-rowupdated-not-firing.html)

TS 02-19-2009 05:29 PM

GridView.RowUpdated not firing
 
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?



Allen Chen [MSFT] 02-20-2009 02:36 AM

RE: GridView.RowUpdated not firing
 
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
allenc@microsoft.com.Please 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:
msdnmg@microsoft.com.

==================================================
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.


Allen Chen [MSFT] 02-26-2009 08:04 AM

RE: GridView.RowUpdated not firing
 
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 03-06-2009 09:46 PM

Re: GridView.RowUpdated not firing
 
yes, i sent it on march 3rd.


"Allen Chen [MSFT]" <v-alchen@online.microsoft.com> wrote in message
news:Rsiebj%23lJHA.5032@TK2MSFTNGHUB02.phx.gbl...
> 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] 03-09-2009 02:03 AM

Re: GridView.RowUpdated not firing
 
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



All times are GMT. The time now is 10:57 AM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.