ASP.NET DropDown not refreshing?

Posts   
 
    
MikeG
User
Posts: 23
Joined: 17-Dec-2006
# Posted on: 04-Feb-2007 12:52:08   

Hi,

Can you please help me understand what I am not doing right?

I have an ASP.NET 2.0 + SQL 2005 + LLBLGen Pro 2 application that has a DropDown and a FormView. Both of these controls are databound through the IDE to a LLBLGenProDataSource (self servicing).

When I run the app, and create a new record via the Form View, the record is inserted in the database, but the DropDown is not updated. If I stop the app, and run it again, the DropDown will then show the new record that was inserted before.

Can you please tell me what I should do to have the controls be refreshed and updated in a timely way, so that if I enter a new record, it is shown in the DropDown?

Thank you, Mike

jmeckley
User
Posts: 403
Joined: 05-Jul-2006
# Posted on: 04-Feb-2007 20:52:59   

Assuming both the dropdown and formview are on the same web form and assuming each has a seperate datasource control. set the dropdown's datasource control's refetch = true just after saving the data to the db.

//save entity to db
MyEntity.Save();

//reload the dropdown list
MyDropDownDataSource.Refetch = true;

This easiest place to call this code is within the preform_work event of the formview datasource... if live persistance = false.

If live persistance = true, you could call refetch in the form view's OnUpdated/OnInserted event. At this point in the life cycle the information has been saved to the db. (I'm not sure if there is an OnInserted event for the formview.)