如何将下拉列表转换为下拉列表 [英] How to convert dropdown list to dropdown checklist

查看:93
本文介绍了如何将下拉列表转换为下拉列表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要将下拉列表转换为下拉列表,所以基本上列表中的项目仍然相同,但应该有复选框。先谢谢。

以下是它的样子: http://timg092191.wordpress .com / 2013/08/16 / ddcl / [ ^ ]

这是代码:

来自AddUser4.aspx

I need to convert my dropdown list to a dropdown checklist, so basically the item on the list is still the same but should have checkboxes on them. Thanks in advanced.
Here's how it looks like: http://timg092191.wordpress.com/2013/08/16/ddcl/[^]
Here's the code:
From AddUser4.aspx

<asp:DropDownList ID="drpSchoolOffice" runat="server" Width="200px">
    </asp:DropDownList>



来自AddUser4.aspx.cs


From AddUser4.aspx.cs

protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            try
            {
                drpSchoolOffice.Items.Clear();
                dtOffice = blSchool.loadSchoolAll();
                if (dtOffice.Rows.Count > 0)
                {
                    foreach (DataRow r in dtOffice.Rows)
                    {
                        drpSchoolOffice.Items.Add(r[2].ToString());
                    }
                }
                SortedList slst = new SortedList();
                foreach (ListItem li in drpSchoolOffice.Items)
                {
                    slst.Add(li.Text, li.Value);
                }
                drpSchoolOffice.DataSource = slst;
                drpSchoolOffice.DataValueField = "Value";
                drpSchoolOffice.DataTextField = "Key";
                drpSchoolOffice.DataBind();
            catch
            {
                Response.Redirect("~/index.aspx");
            }

        }
    }

推荐答案

http://dropdowncheckboxes.codeplex.com/ [ ^ ]


您已经有很多与您的要求相关的文章,其中一个可能是



http://www.dotnetspeaks.com/DisplayArticle.aspx?ID=63 [ ^ ]
You have already many articles related to your requirement one of those might be

http://www.dotnetspeaks.com/DisplayArticle.aspx?ID=63[^]


Refer - ASP.NET中的多选DropDownlist



这里有很多不错的答案。
Refer - Multi-select DropDownlist in ASP.NET.

You will many nice answers here.


这篇关于如何将下拉列表转换为下拉列表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆