I have some code that generates dynamic controls depending on the type of control I want to show. At the moment I just have a date type that displays a text box and a calendar control that are created dynamically.
The controls are built inside a repeater, as there may be more than 1 on the page, which inturn is inside an accordion control. And then I have an Image button control inside the accordion which is clicked to update the database.
I have the code that generates the controls in the Page_Load event outside of "if not ispostback....end if" section ie it fires on every Page_Load.Code:<accordion> <repeater> <controls /> </repeater> <imagebutton /> </accordion>
All of this seems to be working fine. The textbox and calendar controls appear each time the page is loaded.
The problem is if, for example, one of the date textboxes is empty and you type a date into it, when you click the update button when the page first loads, it doesn't save the data. If when the page reloads you enter the date and click the button, it does save it.
I can't work out why the data is not saved on the 1st button click but is on the 2nd one. I presume it's something to do with the page having been posted back once already, but I can't think what is being done differently on the postback compared to when the page first loads.
Does anyone know why this would happen?
I hope all of that makes sense. Let me know if you need more info.



LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks