谢谢拉

解决方案 »

  1.   

    private void Page_Load(object sender, System.EventArgs e)
    {
    if(!IsPostBack) 
    {
    //myconfig.messageokorno("你确定要刷新该值?",this.Button1);
    // 在此处放置用户代码以初始化页面
    string sqlstr = "";
    sqlstr = "select * from u2";
    DataSet ds = new DataSet();
    //System.Data.SqlClient.SqlDataReader read = mydb.RunProcGetReader(sqlstr); //this.CheckBoxList1.DataSource = mydb.RunProc(sqlstr,ds);
    //this.CheckBoxList1.DataValueField = "leixing";
    //this.CheckBoxList1.DataTextField = "leixing";
    //this.CheckBoxList1.DataBind(); this.DropDownList1.DataSource = mydb.RunProc(sqlstr,ds);
    this.DropDownList1.DataValueField = "id";
    this.DropDownList1.DataTextField = "sheng";
    this.DropDownList1.DataBind();
    this.DropDownList1.Items.Insert(0, new ListItem("请选择省份", "请选择省份"));
    this.DropDownList2.Items.Insert(0, new ListItem("请选择城市", ""));
    ds.Clone();
    }
    private void DropDownList1_SelectedIndexChanged(object sender, System.EventArgs e)
    {
    if(this.DropDownList1.SelectedItem.Value == "请选择省份")
    {
    this.DropDownList2.Items.Clear();
    this.DropDownList2.Items.Insert(this.DropDownList1.SelectedIndex,"请选择城市");
    }
    else
    {
    int x = Convert.ToInt32(this.DropDownList1.SelectedItem.Value.Trim());
    string sqlstring1 = "select * from u3 where sheng = '"+ x +"'";
    DataSet myds = new DataSet();

    this.DropDownList2.DataSource = mydb.RunProc(sqlstring1,myds);
    this.DropDownList2.DataValueField = "id";
    this.DropDownList2.DataTextField = "chengshi";
    this.DropDownList2.DataBind();

    myds.Clone();
    }
      

  2.   

    http://www.cnblogs.com/huazi4995/archive/2006/12/05/583111.htmlhttp://www.cnblogs.com/huazi4995/archive/2006/12/05/583101.html