473,324 Members | 2,268 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,324 software developers and data experts.

FormView ModeChange Event Doesn't Fire

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
Feb 13 '07 #1
4 8912
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()
{
FormViewModeEventArgs args1 = new
FormViewModeEventArgs(FormViewMode.Insert, false);
this.OnModeChanging(args1);
if (!args1.Cancel)
{
if (base.IsBoundUsingDataSourceID)
{
this.Mode = args1.NewMode;
this.OnModeChanged(EventArgs.Empty);
}
base.RequiresDataBinding = true;
}
}

Unfortunatelly, you have to handle ModeChanging event and call ChangeMode()
manually with e.NewMode argument:

protected void fv_ModeChanging(object sender, FormViewModeEventArgs 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
Feb 14 '07 #2
Hi again Mark,

No because each template is independent so viewstates for different
templates do not interfere with each other.

--
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
Feb 14 '07 #3
Please forgive me, this reply should have gone to your first post 'Subject:
Limitation of FormView Control?' :-)
--
Milosz
"Milosz Skalecki [MCAD]" wrote:
Hi again Mark,

No because each template is independent so viewstates for different
templates do not interfere with each other.

--
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
Feb 14 '07 #4
Milosz,

Thanks for the quick reply. I didn't think to check whether
ModeChanged was only called when using a DataSourceID-object. I don't
generally use DataSourceID-type objects, preferring a more "explicit"
style of data binding.

- Mark

Feb 14 '07 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: John Bailey | last post by:
I am using a formview with an ObjectDatasource in ASP .Net 2.0. Everything works fine until I try the delete. The ItemDeleting event fires, so I know it should fire my delete method, but instead...
3
by: Michael Glass | last post by:
I'm working on an ASP.Net web app using VS2005 and the .Net 2.0 framework, and I have a serious problem with the page I'm currently working on. The page has, among other things, two FormViews and a...
3
by: Jurgen Appelo | last post by:
I asked this question earlier, but unfortunately the two replies I got did not solve the problem. Here it is again, but now with the code: After an Update my FormView always loses its viewstate...
4
by: J055 | last post by:
Hi I have 2 update buttons in my FormView ('Apply' and 'OK'). I want both buttons to update the data source but the 'OK' button should redirect afterwards. I can see which button is clicked...
3
by: J055 | last post by:
Hi I have a PlaceHolder control inside a FormView EditItemTemplate: <asp:PlaceHolder ID="phResponseText" runat="server"> <tr> <td> <asp:Label ID="lblResponseText"...
5
by: Mark Olbert | last post by:
It appears that FormView controls require the >>exact<< same layout of controls and control types in the various templates in order to function properly. Failure to do so results in a "failure to...
1
by: Chris | last post by:
I have a treeview control, which I use to select a row in a table which will be used to populate a formview. Depending on what node is selected in the treeview I want the formview to be either in...
5
by: =?Utf-8?B?QWRhciBXZXNsZXk=?= | last post by:
Hi All, I have a GridView inside the EditItemTemplate of a FormView. Both FormView and GridView are data bound using an ObjectDataSource. When the FormView's ObjectDataSource object has a...
5
by: =?Utf-8?B?U2F0aXNo?= | last post by:
C#, ASP.NET Q: Have a formview, with a dropdownlist which is bound to a column. This dropdownlist has a datasource of DataSet type. Now my objective is, on Selection Changed of this DropdownList,...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.