Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / ASP.NET / General / May 2007

Tip: Looking for answers? Try searching our database.

Formview edit displaying the same record even when I change the parameter

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Chris - 07 May 2007 16:45 GMT
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
   fvwPage.ChangeMode(FormViewMode.Edit)
Else
   fvwPage.ChangeMode(FormViewMode.Insert)
End If

End Sub

The problem is that when I go to change the objectdatasource parameter when
I go into edit mode it only fires once so the same record displays in the
formview. When I swap from edit to insert and back I can select a new record
to update, but only once until I swap back to insert and then back to edit.
Hope this makes sense. What I am doing wrong? Regards, Chris.

Protected Sub odsPage_Selecting(ByVal sender As Object, ByVal e As
System.Web.UI.WebControls.ObjectDataSourceSelectingEventArgs) Handles
odsPage.Selecting
   e.InputParameters("menuid") = CInt(ViewState("menuid"))
End Sub

Protected Sub odsPage_Updating(ByVal sender As Object, ByVal e As
System.Web.UI.WebControls.ObjectDataSourceMethodEventArgs) Handles
odsPage.Updating
   e.InputParameters("menuid") = CInt(ViewState("menuid"))
End Sub
Chris - 07 May 2007 19:18 GMT
OK I have figured out that the Selecting event of the ObjectDataSource only
seems to fire when you go into e.g. the edit mode for the first time. If I
swap modes i.e. go from edit to readonly and back to edit it fires
everytime. This is too much of a hack. Can anyone point me in a better
direction.

>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
[quoted text clipped - 30 lines]
>    e.InputParameters("menuid") = CInt(ViewState("menuid"))
> End Sub

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.