S
Stephen Davies
I am sure you have all seen a post like this one but its not as easily solved
as the others as you will see from the description below:
Binding a DropDown to a database table (works well all present)
cbCountry.DataSource = objDs;
cbCountry.DataTextField = "CoName";
cbCountry.DataValueField = "CountryID";
cbCountry.DataBind();
Setting the default value to the clients setting from another table (works ok)
ListItem li = cbCountry.Items.FindByValue(SelectedValue);
if ( li != null )
cbCountry.SelectedIndex = cbCountry.Items.IndexOf(li);
User presented with form (correct value presented)
Either submit (with current value) or select a new value
Retrieve value and update database with
dbRowSc["CountryID"] = cbCountry.SelectedValue;
ALWAYS presented with FIRST value in the Dropdown list (yes I am checking is
postback in LoadPage event). Here is the traced output
PageLoad combo selected value is (before if IsPostBack) ->
In BIND of combo values currently set to NZ
USER CLICKS SUBMIT BUTTON
PageLoad combo selected value is (before if IsPostBack) ->AF
CustomValidator event (not related to this control) ->AF
ButtonSave event handler combo value ->AF
SaveValues combo Selected value ->AF
the trace event PageLoad is the first line in the event (AF is the first
entry in the combo)
Any Idea's I am pulling my hair out
as the others as you will see from the description below:
Binding a DropDown to a database table (works well all present)
cbCountry.DataSource = objDs;
cbCountry.DataTextField = "CoName";
cbCountry.DataValueField = "CountryID";
cbCountry.DataBind();
Setting the default value to the clients setting from another table (works ok)
ListItem li = cbCountry.Items.FindByValue(SelectedValue);
if ( li != null )
cbCountry.SelectedIndex = cbCountry.Items.IndexOf(li);
User presented with form (correct value presented)
Either submit (with current value) or select a new value
Retrieve value and update database with
dbRowSc["CountryID"] = cbCountry.SelectedValue;
ALWAYS presented with FIRST value in the Dropdown list (yes I am checking is
postback in LoadPage event). Here is the traced output
PageLoad combo selected value is (before if IsPostBack) ->
In BIND of combo values currently set to NZ
USER CLICKS SUBMIT BUTTON
PageLoad combo selected value is (before if IsPostBack) ->AF
CustomValidator event (not related to this control) ->AF
ButtonSave event handler combo value ->AF
SaveValues combo Selected value ->AF
the trace event PageLoad is the first line in the event (AF is the first
entry in the combo)
Any Idea's I am pulling my hair out