当我单击我的按钮时,我得到SelectedValue = ""

我的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>




我的.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();

        }




我在page load中称呼它是因为当我在
!Page.Ispostback,出现以下错误:


  没有分配的数据源。无法完成回调请求。


我该如何解决这个问题?马上:

ddl_contactList.Text == "MySelectedItemText"



selectedValue == ""selectedItem == ""

最佳答案

将对BindContactLists()的呼叫从Page_Load()方法移动到Page_Init()方法。这允许在页面生命周期的稍后阶段为ViewState绑定设置控件,并允许适当填充SelectedValue属性。

关于c# - RadComboBox选择的值为空,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/12606197/

10-11 05:19