RadComboBox selected value is empty

无人久伴 提交于 2019-12-06 06:01:33

Move your call to BindContactLists() from the Page_Load() method to the Page_Init() method. This allows the control to be setup for ViewState binding later in the page lifecycle, and allow proper population of the SelectedValue property.

It's normal because you re-bind your datas => so you erase your selected value

I suggest you to set your block in !IsPostBack => you don't erase when you post

In PageLoad

if(! IsPostBack)
{

           ddl_contactList.Items.Clear();
            DataTable dt = ContactList.GetContactListsByDep(year, main_code);
            ddl_contactList.DataSource = dt;
            ddl_contactList.DataTextField = "list_desc";
            ddl_contactList.DataValueField = "list_code";
            ddl_contactList.DataBind();


}

And you persist your control with ViewState

Set EnableViewState="true"

make sure your datasource like dataset or datatable fill when page load or init fire

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!