【发布时间】:2015-07-02 20:13:17
【问题描述】:
例如:
你有 2 个数据表,城市和国家:
Country Table
CountryID (Key)
CountryName
City Table
CityID (Key)
CityName
CityCountryID (FK to Country)
在 City 编辑页面中,您希望提供 Country DropDownList,以便当用户选择 Country 时,DropDownList 会更改 City 的 CityCountryID 字段。
CountriesDropDownList.DataSource = GetCountriesDataTable();
CountriesDropDownList.DataTextField = "CountryName";
CountriesDropDownList.DataValueField = "CountryID";
// How to do this?
CountriesDropDownList.SelectedValueDataSource = GetCitiesDataTable(); //error
CountriesDropDownList.SelectedValueField = "CityCountryID"; //error
CountriesDropDownList.DataBind();
【问题讨论】:
标签: asp.net data-binding webforms