Get Help:Ask a Question in our Forums|Report a Bug|More Help Resources
Last post Jun 09, 2009 08:04 AM by Qin Dian Tang - MSFT
Jun 03, 2009 09:58 PM|LINK
We are experiencing a very frustrating situation that I'll do my best to explain.
We have a UserControl with a FormView on it. The UserControl creates a SqlDataSource in its OnLoad event and assigns the ID to the DataSourceID property of the FormView.
At run time, the FormView is displayed in edit mode. We're able to update values on the form and submit them to the database without any problems the very first time we load up the page.
Upon this initial update, the OldValues and NewValues collection as provided in the FormViewUpdateEventArgs during the ItemUpdating event are populated correctly.
After this initial update, subsequent attempts to update the database on this same page do not succeed if we try to set the values back to what they were in the database prior to the initial update.
What's happening is the OldValues collection still contains the values from the very first load of the page prior to our first update. The NewValues collection is populated correctly. This is the case no matter how many updates we attempt.
What would cause the OldValues collection to NOT rebuild upon databinding to the data source AFTER the first update?
Please help! Any and all suggestion will be greatly appreciated!!!
Jun 04, 2009 06:04 AM|LINK
Check following thing:
you are binding initial data if it is not postback if(!IsPostBack)...might be in Page_Load.
Jun 04, 2009 11:25 AM|LINK
Jun 04, 2009 04:12 PM|LINK
That's Cool! Okay now can you pls post some code to look in to.
Jun 04, 2009 08:28 PM|LINK
Jun 09, 2009 08:04 AM|LINK
I suggest you can set DataSourceID of FormView in source code or you can set it in Page_Init event. Here is a good sample for do updating/deleting in FormView using SqlDataSource.