下面代码当中,国家我设置的只是中国,当然也可以从数据里取出别的国家来.
BinderToNationOrArea()绑定国家或地区,省份或洲,城市 #region BinderToNationOrArea()绑定国家或地区,省份或洲,城市
/**//// <summary>
/// 绑定国家或地区
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void BinderToNationOrArea()
...{
//打开数据库的连接
if (cn.State == System.Data.ConnectionState.Closed)
cn.Open();
//国家或地区
SqlCommand cmd = new SqlCommand("select * from NationArea where NationArea = '中国' ",cn);
SqlDataReader sdr = cmd.ExecuteReader();
this.ddlNationOrArea.DataSource = sdr;
this.ddlNationOrArea.DataTextField = "NationArea";
this.ddlNationOrArea.DataValueField = "NationAreaID";
this.ddlNationOrArea.DataBind();
sdr.Close();
//省份或洲
//得到国家的ID
string NationAreaID = this.ddlNationOrArea.SelectedValue;
BinderToNationOrArea()绑定国家或地区,省份或洲,城市 #region BinderToNationOrArea()绑定国家或地区,省份或洲,城市
/**//// <summary>
/// 绑定国家或地区
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void BinderToNationOrArea()
...{
//打开数据库的连接
if (cn.State == System.Data.ConnectionState.Closed)
cn.Open();
//国家或地区
SqlCommand cmd = new SqlCommand("select * from NationArea where NationArea = '中国' ",cn);
SqlDataReader sdr = cmd.ExecuteReader();
this.ddlNationOrArea.DataSource = sdr;
this.ddlNationOrArea.DataTextField = "NationArea";
this.ddlNationOrArea.DataValueField = "NationAreaID";
this.ddlNationOrArea.DataBind();
sdr.Close();
//省份或洲
//得到国家的ID
string NationAreaID = this.ddlNationOrArea.SelectedValue;