allenc
3/9/2009 2:04:00 AM
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