i am developing a website using asp.net 3.5.i have created a cascading dropdownlist for country,state,and city.I am filling the state and city using jquery and web service.
But on page submit i am not able to get the selected value of state and city.it is returning blank.
on page load i am using this.
ListItem stateitem = new ListItem();
stateitem.Text = "Select";
stateitem.Value = "0";
dd_State.Items.Insert(0,stateitem);
I am using jquery and webservice to bind the state and city based on state.
on save button event i am getting the value as.
obj.StateId = Convert.ToInt32(dd_State.SelectedItem.Value);
onj.CityId = Convert.ToInt32(dd_City.SelectedItem.Value);
thanks in advance.
Since you are adding the values client-side, the page won’t know about those values because they were not generated from code-behind. This means that on each postback the dropdown will be restored from viewstate as empty so it has no item to mark as selected.
You have at least two options: