免费视频淫片aa毛片_日韩高清在线亚洲专区vr_日韩大片免费观看视频播放_亚洲欧美国产精品完整版

打開APP
userphoto
未登錄

開通VIP,暢享免費電子書等14項超值服

開通VIP
[DropDownList控件]兩個控件,數(shù)據(jù)間的關(guān)聯(lián) .
 protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            //綁定DropDownList1
            SqlConnection con = new SqlConnection(System.Configuration.ConfigurationSettings.AppSettings["wj"]);
            con.Open();
            SqlCommand cmd = new SqlCommand("select * from tezheng ", con);
            SqlDataReader reader = cmd.ExecuteReader();
            DropDownList1.DataSource = reader;
            DropDownList1.DataTextField = "name";
            DropDownList1.DataValueField = "id";
            DropDownList1.DataBind();
            reader.Close();
            //綁定DropDownList2
            SqlCommand cmd2 = new SqlCommand("select * from tezheng1 where id="+this.industry.SelectedValue, con);
            reader = cmd2.ExecuteReader();//上面定義過reader,這里就不用從新定義
            DropDownList2.DataSource = reader;
            DropDownList2.DataTextField = "tname";
            DropDownList2.DataValueField = "tid";
            DropDownList2.DataBind();
            reader.Close();
}

    protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
    {
        //DropDownList1與DropDownList2數(shù)據(jù)綁定的聯(lián)動性
        string id = this.DropDownList1.SelectedValue;
        SqlConnection con = new SqlConnection(System.Configuration.ConfigurationSettings.AppSettings["wj"]);
        con.Open();
        SqlCommand cmd = new SqlCommand("select * from tezheng1 where id="+id,con);
        SqlDataReader reader = cmd.ExecuteReader();
        this.DropDownList2.DataSource = reader;
        this.DropDownList2.DataTextField = "tname";
        this.DropDownList2.DataValueField = "tid";
        this.DropDownList2.DataBind();
        reader.Close();
        con.Close();
    }
本站僅提供存儲服務(wù),所有內(nèi)容均由用戶發(fā)布,如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,請點擊舉報
打開APP,閱讀全文并永久保存 查看更多類似文章
猜你喜歡
類似文章
asp.net中怎樣調(diào)用存儲過程和存儲過程的寫法
ExecuteNonQuery(),ExecuteScalar()等的區(qū)別
ReportViewer 控件
【ASP.NET】GRIDVIEW控件的一般使用技巧
ASP.NET下備份與還原數(shù)據(jù)庫代碼
C#數(shù)據(jù)庫編程
更多類似文章 >>
生活服務(wù)
分享 收藏 導(dǎo)長圖 關(guān)注 下載文章
綁定賬號成功
后續(xù)可登錄賬號暢享VIP特權(quán)!
如果VIP功能使用有故障,
可點擊這里聯(lián)系客服!

聯(lián)系客服