【发布时间】:2013-06-17 11:30:57
【问题描述】:
我有一个组合框,从一个表中加载组合框后,我从另一个表中获取选定的项目值,并将其绑定到组合框内, 但是我的组合框已加载但没有显示我在其中选择的项目。 这是我的代码。
<ext:ComboBox runat="server" ID="cmbPerson" EmptyText="select person" AllowBlank="false"
Editable="false" Icon="User" Flex="1" ValueField="Id" DisplayField="Name" FieldLabel="">
<Store>
<ext:Store ID="strcmbPerson" runat="server">
<Model>
<ext:Model ID="Model1" runat="server">
<Fields>
<ext:ModelField Name="Id" />
<ext:ModelField Name="Name" />
</Fields>
</ext:Model>
</Model>
</ext:Store>
</Store>
</ext:ComboBox>
protected void Page_Load(object sender, EventArgs e)
{
//I populated combobox from databese,
strcmbPerson.DataSource = person_bll.Get();
strcmbPerson.DataBind();
//later I wanna set selected item value to the "person_obj.PersonId"
cmbPerson.SelectedItem.Value = Convert.ToString(person_obj.PersonId);
}
【问题讨论】:
-
我修复了将组合框值类型设置为字符串的问题。
标签: c# asp.net webforms ext.net