radcombobox总是在回发上选择顶级项目

时间:2012-08-01 17:38:58

标签: asp.net telerik radcombobox

我有一个编辑页面,我根据数据库返回的值设置radcombobox(rcb_ParentCompany)的选定索引。但是,在回发时,组合框中的文本会一直更改为数据集中的顶部项目。有什么想法吗?

protected void Page_Load(object sender, EventArgs e)
    {
         if (IsPostBack)
         {
             BindOperatingNameComboBox(rcb_OperatingName);
             BindParentCompanyComboBox(rcb_ParentCompany);
         }
    }



protected void btn_Edit_Command(object sender, CommandEventArgs e)
    {
        Client ClientToEdit = ClientController.ViewClient(int.Parse(e.CommandArgument.ToString()));

        //Populate Client fields
        txt_ClientName.Text = ClientToEdit.ClientName;
        rcb_OperatingName.Text = ClientToEdit.OperatingName;
        int ParentCompanyIndex = rcb_ParentCompany.FindItemIndexByValue(ClientToEdit.ParentCompanyID.ToString());
        rcb_ParentCompany.SelectedIndex = ParentCompanyIndex;
        txt_Address1.Text = ClientToEdit.Address1;
        txt_Address2.Text = ClientToEdit.Address2;
        txt_Country.Text = ClientToEdit.Country;
        txt_Region.Text = ClientToEdit.Region;
        txt_City.Text = ClientToEdit.City;
        txt_PostalCode.Text = ClientToEdit.PostalCode;
        txt_ClientNote.Text = ClientToEdit.ClientNote;

        tbl_EditServices.Controls.Clear();
        PopulateEditClientPanel(ClientToEdit);

        btn_SaveChanges.CommandArgument = e.CommandArgument.ToString();
        btn_Cancel.CommandArgument = e.CommandArgument.ToString();
    }



protected void BindParentCompanyComboBox(RadComboBox ComboBox)
    {
        DataTable OperatingNames = ClientController.GetExistingClientAndOperatingNames("");
        ComboBox.DataTextField = "ClientName";
        ComboBox.DataValueField = "ClientID";
        ComboBox.DataSource = OperatingNames;
        ComboBox.DataBind();
    }



protected void rcb_ParentCompany_ItemsRequested(object sender, RadComboBoxItemsRequestedEventArgs e)
    {
        BindParentCompanyComboBox((sender as RadComboBox));
    }

1 个答案:

答案 0 :(得分:1)

  

任何想法为什么?

是的,因为您正在if(IsPostBack)而不是if(!IsPostBack)