【发布时间】:2015-01-26 13:02:21
【问题描述】:
<asp:DropDownList runat="server" ValidationGroup="SaveInformation" ID="ddCountries">
</asp:DropDownList>
代码隐藏:带有 ID 和名称的国家/地区将出现在 DataTable 中
ddCountries.DataSource = new GeneralStatic().GetAllCountries();
ddCountries.DataTextField = "Name";
ddCountries.DataValueField = "ID";
ddCountries.DataBind();
ddCountries.Items.Insert(0, "-- Select Country --");
在抛出错误之前它工作正常
'ddCountries' 有一个无效的 SelectedValue,因为它没有 存在于项目列表中。
【问题讨论】: