Hi, I have an ASP.NET 2.0 C# issue that has been troubling me for some time, and if someone could shed some light on this I would appreciate it.
This seems to be a commonly themed question, although most relate to DataGrids and this is a slightly different scenario.
This is completely hypothetical, but say I have a form for editing database information.
This form contains two drop down boxes, one of which determines the content of the other. The problem is that in order for the second drop down box to be updated on the autopostback of the first, it needs to be out with the !IsPostback section. However, if I do this then I cannot add it's details to the database when I submit the form using an event handler.
e.g.
if (!IsPostBack)
{
Drop Down List 1 // This has autopostback set so that when I choose a value it populates Drop Down List 2
}
Drop Down List 2 // This is outside the !IsPostback section so updates when Drop Down Box 1 changes, but wont allow the selected value to be updated by the submit event handler.
Event Handler // Submit values to database.
This seems to be caused by the fact that the page is reinitialised before the new values can be entered into the Database. The database therefore is updated with the old values.
I can ensure the second Drop Down Box is updated by including it in the !IsPostBack section but if I do this, then it's value will not obviously be updated when the value of the first Drop Down Box is changed.
Although this is a hypothetical situation, I have had this problem in many different similar scenarios. I want the ability to Edit & Dynamically change! :) Ian