I get the SelectedValue = ""
when i click on My button .
My aspx :
<telerik:RadComboBox ID="ddl_contactList" runat="server" AutoPostBack="True" CausesValidation="False"
CollapseDelay="0" Culture="ar-EG" ExpandDelay="0" Filter="StartsWith" ItemsPerRequest="10"
MarkFirstMatch="true" Skin="Outlook" EnableAutomaticLoadOnDemand="True" EmptyMessage="-New Menu-"
ShowMoreResultsBox="True" OnSelectedIndexChanged="ddl_contactList_SelectedIndexChanged"
EnableItemCaching="false" EnableLoadOnDemand="True" EnableVirtualScrolling="True">
</telerik:RadComboBox>
My .cs :
private void BindContactLists(int year, int main_code)
{
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();
}
I call it in the page load
because when I call it in the
!Page.Ispostback
, I get the following error:
There is no assigned data source. Unable to complete callback request.
How can I fix this problem? Right now:
ddl_contactList.Text == "MySelectedItemText"
but
selectedValue == ""
and selectedItem == ""
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.