473,663 Members | 2,743 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 8947
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
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
14316
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 I get an error: No parameterless constructor defined for this object, and the delete method is never called. Anyone have any ideas?
3
3873
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 GridView control, each with its own SqlDataSource. FormView1 talks to my Opportunity table and has an ItemTemplate and an EditItemTemplate. FormView2 talks to my Activities table and has an ItemTemplate, InsertItemTemplate and an...
3
3418
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 values. The field values in the FormView are always overwritten by the results of the Update method in the business layer. No matter what I do, the databind always takes place, even when I don't want it to. See the example below. This is a...
4
4679
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 in the ItemCommand event but I can't redirect from here because the ItemUpdated event hasn't fired yet. I can put a variable in the code-behind class which is gets the
3
3633
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" runat="server"></asp:Label></td> <td> <asp:TextBox ID="tbResponseText" runat="server" Text='<%#
5
6904
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 load ViewState" exception when a mode change occurs. Is this correct? If so, it would appear to defeat the >>entire point<< of being able to use customized templates for the various modes. Assuming this limitation exists, what's the...
1
1734
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 update or insert mode. Protected Sub tvwmenu_SelectedNodeChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles tvwmenu.SelectedNodeChanged ViewState("menuid") = menuid ViewState("parentid") = parentid If menuid <0 Then
5
4671
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 SelectParameters with a SessionParameter in the parameters collection and the object stored in the Session is a reference type, the DataGrid fails to enter Line Editing mode. Is this a bug? Is there a workaround for this problem?
5
4027
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, I need to populate a couple of TextBox's. How can I do this? What event does the code go into? The selectionindexchanged even for the DropDownList does not seem to fire. Any help is appreciated. Thanks in advance.
0
8858
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8771
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8634
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6186
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4182
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4349
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2763
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2000
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1757
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.