Click here to Skip to main content
15,917,926 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Respected Sir/ Ma'am,
I want to use a dropdown where i can select multiple values using checkboxes. Can anyone please
give me the step by step description to do so.

Thanks & Regards:-
Sumit Verma
Posted

 
Share this answer
 
Try this..here am fetch the data from db and bind it to the checkbox list..

Hope it will help you..

ASP.NET
<div id="divCheckBoxList" runat="server" style="height: 85px; width: 182px; border: solid 1px #D7DADF;">
                                <asp:panel id="pnlCheckBoxList" runat="server" style="font-family: Arial; font-weight: normal; font-size: small;" xmlns:asp="#unknown">
                                    <div id="divScroll" style="height: 85px; width: auto; overflow-y: scroll; overflow-x: hidden;">
                                        <asp:checkboxlist id="chkLBoxKList" runat="server">
                                            Width="100%" DataTextField=" " DataValueField=" " AutoPostBack="true">
                                        </asp:checkboxlist>
                                    </div>
                                </asp:panel>
                            </div>


C#
try
            {
                s = WebConfigurationManager.ConnectionStrings["con"].ConnectionString;
                con = new SqlConnection(s);
                String str = "";
                for (int i = 0; i <= chkLBoxKList.Items.Count - 1; i++)
                {
                    if (chkLBoxKList.Items[i].Selected)
                    {
                        str = chkLBoxKList.Items[i].Text;
                        if (con.State == ConnectionState.Closed)
                        {
                            con.Open();
                        }                        
                        cmd = new SqlCommand("sp_person_chkbox_list", con);
                        cmd.CommandType = CommandType.StoredProcedure;
                        cmd.Parameters.Add("@empid", SqlDbType.Int).Value = id;
                        cmd.Parameters.Add("@DEPARTMENT", SqlDbType.VarChar).Value = str;
                        cmd.ExecuteNonQuery();
                    }
                }
            }
            catch (SqlException ex)
            {
                Console.WriteLine("SQL Error" + ex.Message.ToString());
                //return 0;
            }
 
Share this answer
 
See this : MultiSelect Dropdown Control[^]

Regards..
 
Share this answer
 
Hi,
If you have add ajax control toolkit to your web application. Then you should see this
http://www.asp.net/ajaxLibrary/AjaxControlToolkitSampleSite/PopupControl/PopupControl.aspx[^].

By use of Popup control you can easily implement it.

If have not implement ajax control toolkit, then follow thatraja or Rohan Leuva answer.

Ask if you need any further help.
Thanks.
 
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