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!!!
Thank you very much for your response. We actually did check to see if we were performing logic based on whether or not it was a postback, and we actually do not have anything written in that manner. Any other suggestions?
Not sure, but you could try creating the SqlDataSource and adding it to your control in Page_Init. Setting its ID on the FormView will still have to go into the Page_Load, I think.
Other than that, I think I'd have to see some code to spot a problem.
Superguppie.
Please remember to click “Mark as Answer” on the post that helps you. This can be beneficial to other community members reading the thread.
When all you've got is a Hammer, Every Problem looks like a Nail. Michael Swain.
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.
ShellyFM
Member
20 Points
21 Posts
OldValues of FormView not being updated with subsequent updates/databindings
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!!!
FormView postback sqldatasource datasource databind OldValues
klpatil
Participant
1290 Points
245 Posts
Re: OldValues of FormView not being updated with subsequent updates/databindings
Jun 04, 2009 06:04 AM|LINK
Hi,
Check following thing:
you are binding initial data if it is not postback if(!IsPostBack)...might be in Page_Load.
HTH
-Kiran
For more solution like this my blog is here
ShellyFM
Member
20 Points
21 Posts
Re: OldValues of FormView not being updated with subsequent updates/databindings
Jun 04, 2009 11:25 AM|LINK
klpatil
Participant
1290 Points
245 Posts
Re: OldValues of FormView not being updated with subsequent updates/databindings
Jun 04, 2009 04:12 PM|LINK
That's Cool! Okay now can you pls post some code to look in to.
HTH
-Kiran
For more solution like this my blog is here
superguppie
All-Star
48225 Points
8679 Posts
Re: OldValues of FormView not being updated with subsequent updates/databindings
Jun 04, 2009 08:28 PM|LINK
Other than that, I think I'd have to see some code to spot a problem.
Please remember to click “Mark as Answer” on the post that helps you. This can be beneficial to other community members reading the thread.
When all you've got is a Hammer, Every Problem looks like a Nail. Michael Swain.
Qin Dian Tan...
All-Star
113532 Points
12480 Posts
Microsoft
Re: OldValues of FormView not being updated with subsequent updates/databindings
Jun 09, 2009 08:04 AM|LINK
Hi ShellyFM,
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.
http://www.aspnettutorials.com/tutorials/database/formviewdata-vb.aspx
Thanks,
If you have any feedback about my replies, please contactmsdnmg@microsoft.com.
Microsoft One Code Framework