ASP.NET Web Form伺服器控制項三級聯動

來源:互聯網
上載者:User

標籤:orm   name   man   服務   update   rgs   src   ddl   end   

<form id="form1" runat="server">         <asp:ScriptManager ID="ScriptManager1" runat="server">        </asp:ScriptManager><asp:UpdatePanel ID="UpdatePanel1" runat="server" style="display:inline-block">                    <ContentTemplate>                        <asp:DropDownList  ID="ddltype1" runat="server" OnSelectedIndexChanged="ddltype1_SelectedIndexChanged"                            AutoPostBack="true">                        </asp:DropDownList>                        &nbsp;                        <asp:DropDownList ID="ddltype2"  runat="server" Visible="false" OnSelectedIndexChanged="ddltype2_SelectedIndexChanged"                            AutoPostBack="true">                        </asp:DropDownList>                        <asp:DropDownList ID="ddltype3"  runat="server" Visible="false">                        </asp:DropDownList>                    </ContentTemplate>                </asp:UpdatePanel>
三級聯動頁面代碼

 

         protected void ddltype1_SelectedIndexChanged(object sender, EventArgs e)        {            string ChannelID = ddltype1.SelectedValue;            if (ChannelID == "")            {                ddltype2.Visible = false;                return;            }            Binder(Convert.ToInt32(ChannelID), ddltype2);        }        protected void ddltype2_SelectedIndexChanged(object sender, EventArgs e)        {            string ChannelID = ddltype2.SelectedValue;            if (ChannelID == "")            {                ddltype3.Visible = false;                return;            }            Binder(Convert.ToInt32(ChannelID), ddltype3);        }        private void Binder(int ChannelID, DropDownList ddl)        {            if (ddl.Items.Count > 0)            {                ddl.Items.Clear();            }            ddl.DataTextField = "User_Group_Name";            ddl.DataValueField = "User_Group_Id";            List<Community.Model.USER_GROUP> lnc = Community.BLL.BUSER_GROUPExtBLL.GetGROUP(ChannelID);            if (lnc.Count > 0)            {                ddl.Visible = true;                ddl.DataSource = lnc;                ddl.DataBind();                ddl.Items.Insert(0, new ListItem("---請選擇----", ""));            }            else            {                ddl.Visible = false;            }        }        
三級聯動後台SelectedIndexChanged事件

 

 

            string type1 = ddltype1.SelectedValue;            string type2 = ddltype2.SelectedValue;            string type3 = ddltype3.SelectedValue;            if (type1 != "" && type2 != "" && type3 != "")            {                channelid = Convert.ToInt32(type3);            }            else if (type1 != "" && type2 != "" && type3 == "")            {                channelid = Convert.ToInt32(type2);            }            else if (type1 != "" && type2 == "" && type3 == "")            {                channelid = Convert.ToInt32(type1);            }            else            {                channelid = 0;            }
三級聯動後台接受值的代碼

 

ASP.NET Web Form伺服器控制項三級聯動

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.