Last post Feb 16, 2012 08:13 PM by Decker Dong - MSFT
Feb 14, 2012 08:59 PM|lynn512|LINK
I'm not sure this is the correct place for this question but...
I'm having issues with a dropdownlist that is being dynamically databound in a function that is called in the Page_Load sub, and there is a load of textboxes on the page for the user to add a new record (which has another sub to insert into the database).
What I would like is for the user to insert a new record and then when the page postback for the dropdownlist to show the new item.
I have debugged the page to find the order in which things appear to be occuring, it appears that the page is re-loaded before the new record has been inserted. I'm not an expert in asp.net VB and would like to know whether there is a way to delay the page
loading until the record is in the database before it re-binds.
Thanks in advance for any help.
Feb 14, 2012 09:09 PM|Rab Nawaz Khan|LINK
if you are using IsPostBack property in page load and calling the function to fill the drop down list inside the IsPostback = false
then it will not fill the new inserted value due to same page postbacks.
call your drop down list data bound function outside the IsPostBack and remember to clear all the Items before it bounds again on PostBack, other wise you will see the duplication in the Drop Down list
Feb 16, 2012 08:13 PM|Decker Dong - MSFT|LINK
Another way is that Bind a Dropdownlist+DataSource（like SqlDataSource，objectDataSource）。And in the same page，there's an insert button；when click it it will insert a record into the db，and the whole page refreshes to read all the data from db again to load