I have the same problem which I have been fighting with all day and can't work out. I have to click Edit and Cancel twice for them to do their action. The first and second click are calling the ModeChanging method so I assume there is something wrong with my
code and the same with justB's code.
If I don't put in the ModeChanging event implementation I get an exception:
"The DetailsView 'dvwWorkItem' fired event ModeChanging which wasn't handled."
I do intend on adding other custom code into this method because certain actions need to happen when you start editing or inserting.
Here is the code I have so far:
protected void dvwWorkItem_ModeChanging(object sender, DetailsViewModeEventArgs e)
{
if (e.NewMode == DetailsViewMode.Edit)
{
dvwWorkItem.ChangeMode(DetailsViewMode.Edit);
}
else if (e.NewMode == DetailsViewMode.ReadOnly)
{
if (e.CancelingEdit == true)
{
dvwWorkItem.ChangeMode(DetailsViewMode.ReadOnly);
}
}
}
I apprecicate any information anyone has that might be able to solve this problem.
Jono
jonorossi
Member
180 Points
38 Posts
Re: trouble with modechanging in detailsview
Jun 27, 2006 03:59 PM|LINK
If I don't put in the ModeChanging event implementation I get an exception:
"The DetailsView 'dvwWorkItem' fired event ModeChanging which wasn't handled."
I do intend on adding other custom code into this method because certain actions need to happen when you start editing or inserting.
Here is the code I have so far:
protected void dvwWorkItem_ModeChanging(object sender, DetailsViewModeEventArgs e) { if (e.NewMode == DetailsViewMode.Edit) { dvwWorkItem.ChangeMode(DetailsViewMode.Edit); } else if (e.NewMode == DetailsViewMode.ReadOnly) { if (e.CancelingEdit == true) { dvwWorkItem.ChangeMode(DetailsViewMode.ReadOnly); } } }I apprecicate any information anyone has that might be able to solve this problem.Jono