62,046
社区成员
发帖
与我相关
我的任务
分享
public string TerminusCode
{
get { return _terminus_code; }
set { this._terminus_code = value; }
}
public partial class UserControls_City_Select_All_In_One : System.Web.UI.UserControl
{
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
BindDDL(DDLzhou_code, new NewMd.Core.WorldCityList().zhouByDisp(), "citypostcode", "cityname");
this.DDLzhou_code.SelectedIndex = 5;//默认为亚洲
this.SetDDlDefaultText(DDLzhou_code, "亚洲");
//验证控件
//this.validate_zhou.Enabled = true;
//this.validate_guojia.Enabled = false;
//this.validate_diqu.Enabled = false;
//this.validate_sheng.Enabled = false;
//this.validate_dijishi.Enabled = false;
//this.validate_xianjishi.Enabled = false;
//选择国家面板=中国
this.DDLzhou_code_SelectedIndexChanged(null, null);
this.Chkzhou_code.Checked = true;
this.Chkzhou_code_CheckedChanged(null, null);
//显示省份面板=未选择
this.DDLguojia_code_SelectedIndexChanged(null, null);
//this.Chkguojia_code.Checked = true;
//this.Chkguojia_code_CheckedChanged(null, null);
}
}
private void BindDDL(DropDownList ddl, DataSet dt, string strValueField, string strTextField)
{
ddl.DataSource = dt;
ddl.DataValueField = strValueField;
ddl.DataTextField = strTextField;
ddl.DataBind();
}
//选择国家代码
protected void DDLguojia_code_SelectedIndexChanged(object sender, EventArgs e)
{
this.DDLdiqu_code.Items.Clear();
this.DDLdiqu_code.Items.Add(new ListItem("请选择地区", "0"));
BindDDL(DDLdiqu_code, new NewMd.Core.WorldCityList().diqu(DDLguojia_code.SelectedValue), "citypostcode", "cityname");
DDLdiqu_code_SelectedIndexChanged(null, null);
}
//选择地区代码.联动
protected void DDLdiqu_code_SelectedIndexChanged(object sender, EventArgs e)
{
this.DDLsheng_code.Items.Clear();
this.DDLsheng_code.Items.Add(new ListItem("请选择省份", "0"));
BindDDL(DDLsheng_code, new NewMd.Core.WorldCityList().sheng(DDLdiqu_code.SelectedValue), "citypostcode", "cityname");
DDLsheng_code_SelectedIndexChanged(null, null);
}
//选择省份代码.联动
protected void DDLsheng_code_SelectedIndexChanged(object sender, EventArgs e)
{
this.DDLdijishi_code.Items.Clear();
this.DDLdijishi_code.Items.Add(new ListItem("请选择地级市", "0"));
BindDDL(DDLdijishi_code, new NewMd.Core.WorldCityList().dijishi(DDLsheng_code.SelectedValue), "citypostcode", "cityname");
DDLdijishi_code_SelectedIndexChanged(null, null);
}
//选择地级市.联动
protected void DDLdijishi_code_SelectedIndexChanged(object sender, EventArgs e)
{
this.DDLxianjishi_code.Items.Clear();
this.DDLxianjishi_code.Items.Add(new ListItem("请选择县级市", "0"));
BindDDL(DDLxianjishi_code, new NewMd.Core.WorldCityList().xianjishi(DDLdijishi_code.SelectedValue), "citypostcode", "cityname");
}
private DropDownList GetSelectCity()
{
DropDownList Retval = DDLzhou_code;
if (Panel6.Visible)
{
return DDLxianjishi_code;
}
if (Panel5.Visible)
{
return DDLdijishi_code;
}
if (Panel4.Visible)
{
return DDLsheng_code;
}
if (Panel3.Visible)
{
return DDLdiqu_code;
}
if (Panel2.Visible)
{
return DDLguojia_code;
}
if (Panel1.Visible)
{
return DDLzhou_code;
}
return Retval;
}
#endregion
//获取城市代码
public NewMd.Model.City_CitySelect_all GetCity()
{
return 选定的城市代码;
}
/// <summary>
/// 提供数据回显的代码
/// </summary>
/// <param name="code">输入城市代码</param>
/// <returns>返回设定是否成功,UI是否回显</returns>
public bool setLocationCode(string code)
{
//安全检查位数
if (code.Length != 9)
{
return false;
}
if (code.Substring(1, 8) != "00000000")
{
this.Chkzhou_code.Checked = true;
this.Chkzhou_code_CheckedChanged(null, null);
}
if (code.Substring(3, 6) != "000000")
{
this.Chkguojia_code.Checked = true;
this.Chkguojia_code_CheckedChanged(null, null);
}
if (code.Substring(4, 5) != "00000")
{
this.Chkdiqu_code.Checked = true;
this.Chkdiqu_code_CheckedChanged(null, null);
}
if (code.Substring(5, 4) != "0000")
{
this.Chksheng_code.Checked = true;
this.Chksheng_code_CheckedChanged(null, null);
}
if (code.Substring(7, 2) != "00")
{
this.Chkdijishi_code.Checked = true;
this.Chkdijishi_code_CheckedChanged(null, null);
}
//绑定洲的代码...1
BindDDL(DDLzhou_code, new NewMd.Core.WorldCityList().zhouByDisp(), "citypostcode", "cityname");
this.setDDLDefaultValue(this.DDLzhou_code, code.Substring(0, 1) + "00000000");
DDLzhou_code_SelectedIndexChanged(null, null);
//国家2
BindDDL(DDLguojia_code, new NewMd.Core.WorldCityList().guojiaBydisp(code), "citypostcode", "cityname");
this.setDDLDefaultValue(this.DDLguojia_code, code.Substring(0, 3) + "000000");
DDLguojia_code_SelectedIndexChanged(null, null);
//地区4
BindDDL(DDLdiqu_code, new NewMd.Core.WorldCityList().diqu(code), "citypostcode", "cityname");
this.setDDLDefaultValue(this.DDLdiqu_code, code.Substring(0, 4) + "00000");
DDLdiqu_code_SelectedIndexChanged(null, null);
//省份5
BindDDL(DDLsheng_code, new NewMd.Core.WorldCityList().sheng(DDLdiqu_code.SelectedValue), "citypostcode", "cityname");
this.setDDLDefaultValue(this.DDLsheng_code, code.Substring(0, 5) + "0000");
DDLsheng_code_SelectedIndexChanged(null, null);
//地级市7
BindDDL(DDLdijishi_code, new NewMd.Core.WorldCityList().dijishi(DDLsheng_code.SelectedValue), "citypostcode", "cityname");
this.setDDLDefaultValue(this.DDLdijishi_code, code.Substring(0, 7) + "00");
DDLdijishi_code_SelectedIndexChanged(null, null);
//县级市
BindDDL(DDLxianjishi_code, new NewMd.Core.WorldCityList().xianjishi(DDLdijishi_code.SelectedValue), "citypostcode", "cityname");
this.setDDLDefaultValue(this.DDLxianjishi_code, code);
return true;
}
}