user control with a dropdown

M

mkarbarz

Hi,

I have a user control that contains a dropdownlist. I populate the
list in page load event of the user control in the following manner:

if (!IsPostBack) {
_ddUserCity.DataSourceID = "SqlDataSource1";
_ddUserCity.DataTextField = "user_city";
_ddUserCity.DataValueField = "user_city";
_ddUserCity.DataBind();
}

The problem is with the selected index property. The list always
selects the first element on pageload even if it's a postback .
Dropdownlist is autopostback enabled and has view state enabled. I
cannot for the life of me figure out why the selected index is not
being preserved on page postback.

Any help would be appreciated.

Thanks
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top