Click here to Skip to main content
15,891,423 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
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>

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");
            }

        }
    }
Posted
Updated 16-Aug-13 6:11am
v6

 
Share this answer
 
You have already many articles related to your requirement one of those might be

http://www.dotnetspeaks.com/DisplayArticle.aspx?ID=63[^]
 
Share this answer
 
Comments
timJosh 16-Aug-13 12:15pm    
I have seen and used this but it doesn't work I was wondering if you could teach me what exactly would I have to do if you have a spare time thanks
Thanks7872 16-Aug-13 13:00pm    
if you could teach me?

You are not even ready to try it your self even after having a code?...huh....!

If it work for others than why not for you? Try to identify the cause. Asking some body to accomplish your task is not a good solution.
Refer - Multi-select DropDownlist in ASP.NET.

You will many nice answers here.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900