标签: checkboxlist

如何在ASP.NET C#中使用foreach获取CheckBoxList中所选项的值?

我有一个像这样的CheckBoxList:

<asp:CheckBoxList ID="CBLGold" runat="server" CssClass="cbl">
    <asp:ListItem Value="TGJU"> TG </asp:ListItem>
    <asp:ListItem Value="GOLDOZ"> Gold </asp:ListItem>
    <asp:ListItem Value="SILVEROZ"> Silver </asp:ListItem>
    <asp:ListItem Value="NERKH"> NE </asp:ListItem>
    <asp:ListItem Value="TALA"> Tala </asp:ListItem>
    <asp:ListItem Value="YARAN"> Sekeh </asp:ListItem>
</asp:CheckBoxList>
Run Code Online (Sandbox Code Playgroud)

现在我想使用foreach从此CheckBoxList获取所选项的值,并将值放入列表中.

注意:我希望代码简短.

c# asp.net foreach list checkboxlist

70
推荐指数
3
解决办法
29万
查看次数

如何验证用户在CheckBoxList中选择了至少一个复选框?

我有一个CheckBoxList控件,我想让用户检查至少一个盒子,如果他们检查每一个,或3个,甚至只是一个,都没关系.

本着asp.net的验证控件的精神,我可以使用什么来强制执行此操作?我也在使用Ajax验证扩展器,所以如果它看起来像其他控件,而不是代码隐藏中的一些俗气的服务器验证方法,那将会很好.

<asp:CheckBoxList RepeatDirection="Horizontal" RepeatLayout="Table" RepeatColumns="3" ID="ckBoxListReasons" runat="server">
    <asp:ListItem Text="Preliminary Construction" Value="prelim_construction" />
    <asp:ListItem Text="Final Construction" Value="final_construction" />
    <asp:ListItem Text="Construction Alteration" Value="construction_alteration" />
    <asp:ListItem Text="Remodel" Value="remodel" />
    <asp:ListItem Text="Color" Value="color" />
    <asp:ListItem Text="Brick" Value="brick" />
    <asp:ListItem Text="Exterior Lighting" Value="exterior_lighting" />
    <asp:ListItem Text="Deck/Patio/Flatwork" Value="deck_patio_flatwork" />
    <asp:ListItem Text="Fence/Screening" Value="fence_screening" />
    <asp:ListItem Text="Landscape - Front" Value="landscape_front" />
    <asp:ListItem Text="Landscape - Side/Rear" Value="landscape_side_rear" />
    <asp:ListItem Text="Other" Value="other" />
</asp:CheckBoxList>
Run Code Online (Sandbox Code Playgroud)

.net asp.net validation checkbox checkboxlist

35
推荐指数
2
解决办法
9万
查看次数

MVC3中的CheckboxList查看并获取传递给控制器​​的已检查项目

我有一个MoreInfo类:

public class MoreInfo
{
        public string Name { get; set; }
        public string selectedCheckboxItems {get; set;}
}
Run Code Online (Sandbox Code Playgroud)

我想知道如何在视图上创建一个复选框列表,并在提交时将已检查的项目传递给我的控制器.

我将如何创建复选框列表以及如何传递所有选中的项目并进行处理?

asp.net-mvc checkboxlist asp.net-mvc-3

25
推荐指数
2
解决办法
4万
查看次数

如何循环通过一个复选框列表,找到已检查和未检查的内容

我正试图循环通过复选框列表的项目.如果选中它,我想设置1个值.如果没有,我想设置另一个值.我正在使用下面但它只给我检查项目:

foreach (DataRowView myRow in clbIncludes.CheckedItems)
{
    MarkVehicle(myRow);
}
Run Code Online (Sandbox Code Playgroud)

TIA!

.net c# checkboxlist

21
推荐指数
3
解决办法
13万
查看次数

为什么删除它:ASP.NET MVC CheckBoxList(没有MVCContrib)

为什么从ASP.NET MVC预览版本5中删除了CheckBoxList

目前我没有看到任何方式可以创建复选框列表(名称相似但ID不同),因此人们可以从列表中选择0-1个以上的选项.

CheckBoxListMVCContrib库中存在一个列表,但不推荐使用.我可以理解其他HtmlHelpers,但似乎没有替代CheckBoxList预览5.

我想创建一个非常简单的列表,如下所示,但使用ASP.NET MVC预览版本5的最佳方法是什么?

<INPUT TYPE="checkbox" NAME="Inhoud" VALUE="goed"> goed
<INPUT TYPE="checkbox" NAME="Inhoud" VALUE="redelijk"> redelijk
<INPUT TYPE="checkbox" NAME="Inhoud" VALUE="matig"> matig
<INPUT TYPE="checkbox" NAME="Inhoud" VALUE="slecht"> slecht
Run Code Online (Sandbox Code Playgroud)

asp.net-mvc checkboxlist

19
推荐指数
2
解决办法
2万
查看次数

如何禁用checkedlistbox中的复选框?

我在一个选中的列表框中有一些项目,我想禁用其中第一项的复选框.
即我想禁用CheckedListBox中的第一项,因为我想用视觉告诉用户该选项不可用.

c# checkboxlist winforms

16
推荐指数
6
解决办法
4万
查看次数

Angular获取选中的CheckBoxes

我有一个使用angular的动态填充复选框列表.

 <div ng-repeat="X in XList">
     <label>{{X.Header}}</label>
     <input type="checkbox" name="X" value="{{X.Item.Id}}" />
     <p>{{X.Header}}</p>
 </div>
Run Code Online (Sandbox Code Playgroud)

我想要一个方法来检索所有选中的复选框的列表.通常我会用

 $('input[name=checkboxlist]:checked').each(function()
{
}
Run Code Online (Sandbox Code Playgroud)

但这对于角度来说是不可接受的....那么有适当的方法吗?

javascript checkbox checkboxlist angularjs

16
推荐指数
1
解决办法
2万
查看次数

jqGrid多复选框自定义编辑类型解决方案

对于那些试图了解jqGrid自定义编辑类型的人...

我创建了一个多复选框表单元素,并认为我会分享.这是使用3.6.4版本构建的.如果有人有更有效的解决方案,请传递它.

在colModel中,相应的编辑字段如下所示:

edittype:'custom'
editoptions:{ custom_element:MultiCheckElem, custom_value:MultiCheckVal, list:'Check1,Check2,Check3,Check4' }
Run Code Online (Sandbox Code Playgroud)

以下是javascript函数(顺便说一句,当复选框列表在DIV块中时,它也有效 - 经过一些修改):

//————————————————————
// Description:
//   MultiCheckElem is the "custom_element" function that builds the custom multiple check box input
//   element. From what I have gathered, jqGrid calls this the first time the form is launched. After
//   that, only the "custom_value" function is called.
//
//   The full list of checkboxes is in the jqGrid "editoptions" section "list" tag (in the options
//   parameter).
//————————————————————
function MultiCheckElem( value, options …
Run Code Online (Sandbox Code Playgroud)

jqgrid checkboxlist multi-select

15
推荐指数
0
解决办法
6407
查看次数

如何在ASP.NET MVC中创建CheckBoxListFor扩展方法?

我知道ListBoxForASP.NET MVC Html助手扩展方法中有一个扩展方法,但我一直认为复选框列表比列表框更加用户友好.

CheckBoxList在旧的WebForms中有一个非常方便的控制,但显然现在已经不在了.

问题是,为什么ASP.NET MVC中没有办法创建复选框列表?如何编写自己的扩展方法来创建复选框列表并以类似的方式运行ListBoxFor

.net asp.net asp.net-mvc checkboxlist

15
推荐指数
1
解决办法
3万
查看次数

ng2智能表复选框在所有页面上都不是持久的

我是ng2-smart-tables的新手.我正在尝试从GitHub页面修改下面的示例,以便在从一个页面移动到另一个页面时复选框不会消失.

import { Component } from '@angular/core';

@Component({
  selector: 'basic-example-multi-select',
  template: `
    <ng2-smart-table [settings]="settings" [source]="data"></ng2-smart-table>
  `,
})
export class BasicExampleMultiSelectComponent {

  settings = {
    selectMode: 'multi',
    columns: {
      id: {
        title: 'ID',
      },
      name: {
        title: 'Full Name',
      },
      username: {
        title: 'User Name',
      },
      email: {
        title: 'Email',
      },
    },
  };

  data = [
    {
      id: 1,
      name: 'Leanne Graham',
      username: 'Bret',
      email: 'Sincere@april.biz',
    },
    {
      id: 2,
      name: 'Ervin Howell',
      username: 'Antonette',
      email: 'Shanna@melissa.tv',
    },
    {
      id: 3, …
Run Code Online (Sandbox Code Playgroud)

javascript checkboxlist ng2-smart-table angular

13
推荐指数
1
解决办法
2410
查看次数