动态地将Checkboxlist添加到下拉列表 [英] Adding Checkboxlist to dropdownlist dynamically

查看:92
本文介绍了动态地将Checkboxlist添加到下拉列表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在网络表单中动态添加包含checkboxlist的下拉列表。在Web表单下拉列表和动态添加的checkboxlist。我在类文件中使用c#编码添加这些控件,让我知道如何添加多个选中的checkboxlist

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

推荐答案

检查一次



多选DropDownList(DropDownList内的CheckBoxList) ) [ ^ ]





http://www.dotnetgallery.com/kb/resource55-Checkbox-list-in-Dropdown-using-Aspnet-Ajax-PopupControlExtender -control.aspx [ ^ ]
check it once

A Multiple Selection DropDownList (a CheckBoxList Inside a DropDownList)[^]


http://www.dotnetgallery.com/kb/resource55-Checkbox-list-in-Dropdown-using-Aspnet-Ajax-PopupControlExtender-control.aspx[^]


我认为这个链接应该有用 dotnetspeaks.com/DisplayArticle.aspx?ID=63
I think this link should be helpful dotnetspeaks.com/DisplayArticle.aspx?ID=63


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%";



通过添加此RadCombobox控件和

数据源分配给radcombobox


By adding this RadCombobox control and
datasource assign to radcombobox

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


这篇关于动态地将Checkboxlist添加到下拉列表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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