本文整理汇总了C#中System.Web.UI.WebControls.CheckBoxList类的典型用法代码示例。如果您正苦于以下问题:C# CheckBoxList类的具体用法?C# CheckBoxList怎么用?C# CheckBoxList使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
CheckBoxList类属于System.Web.UI.WebControls命名空间,在下文中一共展示了CheckBoxList类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: AddColorInColorCollections
/// <summary>
/// Add Style in CheckBoxes Color Collection.
/// </summary>
public static void AddColorInColorCollections(CheckBoxList ColorchkBxs)
{
for (int i = 0; i < ColorchkBxs.Items.Count; i++)
{
ColorchkBxs.Items[i].Attributes.Add("style", "color:" + ColorchkBxs.Items[i].Text + ";");
}
}
示例2: CheckListToStr
public static string CheckListToStr(CheckBoxList Obj)
{
string text = "";
int count = Obj.Items.Count;
int arg_19_0 = 0;
checked
{
int num = count - 1;
int num2 = arg_19_0;
bool flag;
while (true)
{
int arg_5D_0 = num2;
int num3 = num;
if (arg_5D_0 > num3)
{
break;
}
flag = Obj.Items[num2].Selected;
if (flag)
{
text = text + "," + Obj.Items[num2].Value;
}
num2++;
}
flag = (Operators.CompareString(text, "", false) != 0);
if (flag)
{
text = Strings.Right(text, Strings.Len(text) - 1);
}
return text;
}
}
示例3: Insert
/// <summary>
/// 添加
/// </summary>
public bool Insert(Model_Resource resourceModel, CheckBoxList cbl)
{
bool b = false;
using (TransactionScope tranScope = new TransactionScope())
{
int id = dataFactory.ResourceDal.AddEntity(resourceModel).ResourceID;
if (id > 0)
{
//添加到资源权限表Privilege
foreach (ListItem li in cbl.Items)
{
if (li.Selected == true)
{
int operateId = Convert.ToInt32(li.Value);
Owen.Model.Model_Privilege mPrivilege = new Model_Privilege();
mPrivilege.OperateID = operateId;
mPrivilege.ResourceID = id;
mPrivilege.Remark = string.Empty;
new BLL_Privilege().AddEntity(mPrivilege);
}
}
tranScope.Complete();
b = true;
}
}
return b;
}
示例4: UpdateEntity
/// <summary>
/// 修改
/// </summary>
/// <param name="entity">泛型实体</param>
/// <returns></returns>
public bool UpdateEntity(Owen.Model.Model_Distributor entity, CheckBoxList cbl)
{
bool b = false;
using (TransactionScope tranScope = new TransactionScope())
{
if (entity == null || entity.DistributorID == 0) tranScope.Dispose();
new BLL_DistributorRelation().DeleteEntity(string.Format(" DistributorID = {0} ", entity.DistributorID));
foreach (ListItem li in cbl.Items)
{
int hosId = Convert.ToInt32(li.Value);
if (li.Selected == true)
{
Owen.Model.Model_DistributorRelation mDistributorRelation = new Owen.Model.Model_DistributorRelation();
mDistributorRelation.DistributorID = entity.DistributorID;
mDistributorRelation.HospitalID = hosId;
new BLL_DistributorRelation().AddEntity(mDistributorRelation);
}
}
dataFactory.DistributorDal.UpdateEntity(entity);
tranScope.Complete();
b = true;
}
return b;
}
示例5: GetCheckBoxSelectValues
public string GetCheckBoxSelectValues(CheckBoxList control)
{
string strCheckBoxLibrary = "";
if (control.SelectedIndex == -1)
{
//for (int i = 0; i < control.Items.Count; i++)
//{
// if (control.Items[i].Text != "全选")
// {
// strCheckBoxLibrary += control.Items[i].Value + ",";
// }
//}
//return strCheckBoxLibrary.Trim(',');
return "";
}
else
{
for (int i = 0; i < control.Items.Count; i++)
{
if (control.Items[i].Text != "全选" && control.Items[i].Selected == true)
{
strCheckBoxLibrary += control.Items[i].Value + ",";
}
}
return strCheckBoxLibrary.Trim(',');
}
}
示例6: setCheckBoxList
public void setCheckBoxList(CheckBoxList chl, DataSet ds, string display, string value)
{
chl.DataSource = ds;
chl.DataTextField = display;
chl.DataValueField = value;
chl.DataBind();
}
示例7: RenderGoals
/// <summary>
/// Renders the goals.
/// </summary>
/// <param name="doc">The document.</param>
private void RenderGoals(XDocument doc)
{
Assert.ArgumentNotNull((object)doc, "doc");
List<string> selected = new List<string>();
foreach (XElement element in doc.Descendants((XName)"event"))
selected.Add(XElementExtensions.GetAttributeValue(element, "name"));
CheckBoxList checkBoxList = new CheckBoxList() { ID = "GoalsCheckBoxList" };
this.GoalsList.Controls.Add((System.Web.UI.Control)checkBoxList);
System.Web.UI.Page page = TrackingFieldPageBase.GetPage();
if (page == null || page.IsPostBack)
return;
GoalsPipelineArgs args = new GoalsPipelineArgs();
args.RulesFolderID = SitecoreIDs.GoalsRulesFolderID;
ID id = ShortID.DecodeID(Sitecore.Context.Request.QueryString["id"]);
if (!id.IsNull)
args.ContextItem = Sitecore.Context.ContentDatabase.GetItem(id);
CorePipeline.Run("uiGetGoals", args);
TrackingFieldPageBase.RenderCheckBoxList(checkBoxList, args.PageEvents.OrderBy(e => e.DisplayName), selected);
}
示例8: MultipleSelectControl
public MultipleSelectControl(MultipleSelect item, RepeatDirection direction)
{
this.item = item;
l = new Label();
l.Text = item.Title;
l.CssClass = "label";
l.AssociatedControlID = item.Name;
this.Controls.Add(l);
list = new CheckBoxList();
list.RepeatDirection = direction;
list.ID = item.Name;
list.CssClass = "alternatives";
list.DataSource = item.GetChildren();
list.DataTextField = "Title";
list.DataValueField = "ID";
list.DataBind();
this.Controls.Add(list);
if (item.Required)
{
cv = new CustomValidator { Display = ValidatorDisplay.Dynamic, Text = "*" };
cv.ErrorMessage = item.Title + " is required";
cv.ServerValidate += (s, a) => a.IsValid = !string.IsNullOrEmpty(AnswerText);
cv.ValidationGroup = "Form";
this.Controls.Add(cv);
}
}
示例9: ChkListFill
public static void ChkListFill(ref CheckBoxList chkl, object list)
{
chkl.DataTextField = listDefaultDataTextField;
chkl.DataValueField = listDefaultDataValueField;
chkl.DataSource = list;
chkl.DataBind();
}
示例10: McmsWebQuestion
public McmsWebQuestion(string strId, bool bRequired, string strRequiredText, string strQuestion, string strControlBase, RepeatDirection rdLayout, string[] strResponses)
: base(strId, "mcms", bRequired, strRequiredText, strQuestion)
{
this.m_listBox = new ListBox();
this.m_checkBoxList = new CheckBoxList();
this.m_listControl = null;
if (strControlBase == "checkbox")
{
this.m_checkBoxList.RepeatDirection = rdLayout;
this.m_listControl = this.m_checkBoxList;
}
else
{
this.m_listBox.SelectionMode = ListSelectionMode.Multiple;
this.m_listControl = this.m_listBox;
}
foreach (string text in strResponses)
{
this.m_listControl.Items.Add(new ListItem(text));
}
this.m_listControl.ID = "lst_" + strId;
this.Controls.Add(this.m_listControl);
if (bRequired)
{
ListControlValidator child = new ListControlValidator();
child.EnableClientScript = false;
child.Text = strRequiredText;
child.Display = ValidatorDisplay.Dynamic;
child.ControlToValidate = this.m_listControl.ID;
this.Controls.Add(child);
}
this.Controls.Add(new LiteralControl("</p>"));
}
示例11: GetCheckedCheckBoxListItems
public static String GetCheckedCheckBoxListItems(CheckBoxList checkBoxList)
{
lock (checkBoxList.Items.SyncRoot)
{
return checkBoxList.Items.Cast<ListItem>().Where(li => li.Selected).Select(li => li.Text).Join(";");
}
}
示例12: CargarPermisosCheckeados
public void CargarPermisosCheckeados(CheckBoxList chklist, int id)
{
DataSet ds = new DataSet();
ds = ListadoDePermisos();
chklist.Items.Clear();
if (ds.Tables[0].Rows.Count > 0)
{
for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
{
chklist.Items.Add(new ListItem(ds.Tables[0].Rows[i]["Permiso_desc"].ToString(), ds.Tables[0].Rows[i]["Permiso_id"].ToString()));
}
ds = new DataSet();
ds = ListadoDePermisos(id);
if (ds.Tables[0].Rows.Count > 0)
{
for (int i = 0; i < chklist.Items.Count; i++)
{
for (int j = 0; j < ds.Tables[0].Rows.Count; j++)
{
if (chklist.Items[i].Value == ds.Tables[0].Rows[j]["PERMISO_ID"].ToString())
{
chklist.Items[i].Selected = true;
}
}
}
}
}
}
示例13: BindList
private void BindList()
{
if (siteSettings == null) { siteSettings = CacheHelper.GetCurrentSiteSettings(); }
//why is this null here, its declared
if (chkAllowedRoles == null)
{
chkAllowedRoles = new CheckBoxList();
if (this.Controls.Count == 0) { this.Controls.Add(chkAllowedRoles); }
}
chkAllowedRoles.Items.Clear();
ListItem allItem = new ListItem();
allItem.Text = Resource.RolesAllUsersRole;
allItem.Value = "All Users";
chkAllowedRoles.Items.Add(allItem);
using (IDataReader reader = Role.GetSiteRoles(siteSettings.SiteId))
{
while (reader.Read())
{
ListItem listItem = new ListItem();
listItem.Text = reader["DisplayName"].ToString();
listItem.Value = reader["RoleName"].ToString();
if ((selectedRoles.LastIndexOf(listItem.Value + ";") > -1))
{
listItem.Selected = true;
}
chkAllowedRoles.Items.Add(listItem);
}
}
}
示例14: CheckItem
/// <summary>
/// 根据提供的Id字符串,将列表中的项选中
/// </summary>
/// <param name="itemid">Id字符串,由,分隔</param>
/// <param name="checkboxlist">CheckBoxList控件</param>
public static void CheckItem(string itemid, CheckBoxList checkboxlist)
{
foreach (ListItem li in checkboxlist.Items)
{
if (itemid.IndexOf(li.Value) != -1)
li.Selected = true;
}
}
示例15: FillCheckBoxList
public void FillCheckBoxList(CheckBoxList chk, DataTable mydt, string textField, string valueFeild)
{
chk.DataSource = mydt;
chk.DataValueField = valueFeild;
chk.DataTextField = textField;
chk.DataBind();
chk.Items.Insert(0, new ListItem { Value = "0", Text = "All", Selected = false });
}