Retaining Dropdownlist selectedvalue after postback in ASP.NET Web form.
Posted on 2006-03-25
Using VB.NET I have two dropdownlists which are populated by a typed dataset. The Dropdown list values work fine, but at postback I want to be able to retain the selectedvalue. I have done this within a datagrid template column using the databinder.eval(Container, DataItem.Fieldname) method. But when trying this same method on dropdownlist on a form, there is no container item. I have tired putting the follwoing statement using my dataset in place of the container and data item. Ex: SelectedValue='<%# DataBinder.Eval(CfDataSet1, "Tables[CityCodeList].DefaultView..CityCode") %>'>. But obviously this did not work. Can you tell me how this is accomplished?