Hi Mark,
I had a look at the FormView control's code, and it seems ModeChanged event
is only raised when formview is bound to a datasource control (i.e.
sqldatasource, objedatasource etc). See it for yourself:
private void HandleNew()
{
FormViewModeEve ntArgs args1 = new
FormViewModeEve ntArgs(FormView Mode.Insert, false);
this.OnModeChan ging(args1);
if (!args1.Cancel)
{
if (base.IsBoundUs ingDataSourceID )
{
this.Mode = args1.NewMode;
this.OnModeChan ged(EventArgs.E mpty);
}
base.RequiresDa taBinding = true;
}
}
Unfortunatelly, you have to handle ModeChanging event and call ChangeMode()
manually with e.NewMode argument:
protected void fv_ModeChanging (object sender, FormViewModeEve ntArgs e)
{
fv.ChangeMode(e .NewMode);
// rebind the data
fv.DataSource = anyDataSource;
fv.DataBind();
}
Done.
--
Milosz
"Mark Olbert" wrote:
I'm trying to understand how to respond to mode changing events in a FormView control. I'm not using datasource controls, so I have
to do more of the plumbing myself.
Do I have to call the ChangeMode() method in the ModeChanging event handler?
Why doesn't the ModeChanged event fire? I can see the mode in the process of changing, because my ModeChanging handler gets called,
but then the ModeChanged handler never gets called.
- Mark