Click here to Skip to main content
15,888,454 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I want to add dropdownlist which contain checkboxlist dynamically in web form. In web form dropdownlist and checkboxlist added dynamically. I adding these control using c# coding in class file so let me know how to add multiple selected checkboxlist
Posted
Updated 18-Nov-13 1:27am
v5
Comments
Manisha D. 12-Nov-13 5:06am    
i have create checkboxlist dynaamically using c# coding

I think this link should be helpful dotnetspeaks.com/DisplayArticle.aspx?ID=63
 
Share this answer
 
C#
RadComboBox accesslists = new RadComboBox();
           accesslists.Attributes.Add("runat", "server");
           accesslists.Attributes.Add("EnableCheckAllItemsCheckBox", "true");
           accesslists.Attributes.Add("EmptyMessage", "Select");
           accesslists.CheckBoxes = true;
           accesslists.MaxHeight = 200;
           accesslists.Width = 400;
           accesslists.AutoPostBack = true;
           accesslists.Style["margin-left"] = "5.6%";

By adding this RadCombobox control and
datasource assign to radcombobox
C#
con.Open();
DataTable dt = new DataTable();
SqlDataAdapter da = new SqlDataAdapter("SELECT Brand.BrandName FROM Brand INNER JOIN ProductBrand ON Brand.Brand_ID = ProductBrand.Brand_ID INNER JOIN Product ON ProductBrand.Product_ID = Product.Product_ID WHERE (Product.Product_ID = 1) ORDER BY Brand.BrandName", con);
da.Fill(dt);
accesslists.DataSource = dt;
accesslists.SelectedIndexChanged += new RadComboBoxSelectedIndexChangedEventHandler(accesslists_SelectedIndexChanged);

foreach (DataRow row in dt.Rows)
{
    RadComboBoxItem item = new RadComboBoxItem();
    item.Text = row["BrandName"].ToString();
    item.Value = row["BrandName"].ToString();
    item.Attributes.Add("BrandName", row["BrandName"].ToString());
    accesslists.Items.Add(item);
    item.DataBind();
}
con.Close();


By this way we create dropdownlist of multiple selection checkboxes
 
Share this answer
 
v2
Why do you not using telerik controls? They are just awesome😊
 
Share this answer
 
Comments
Manisha D. 12-Nov-13 4:49am    
I dont know how to add telerik control dynamically in class file
Mishra Laxmikant 12-Nov-13 9:07am    
telerik controls are paid. but you can download for demo/trial version.
Manisha D. 14-Nov-13 2:51am    
i just taken radcombobox and i fetching data from database which will be assigned to radcombobox but while seeing in browser it not shows me data. I have used sqldatareader for fetching data.
Mishra Laxmikant 14-Nov-13 3:20am    
would you please share code?
Hi
I think the information in the following link will help:

www.dotnetfunda.com

regards
 
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