我正在尝试为数据库记录构建一个"编辑"页面,该页面可以编辑并保存回数据库.其中一个字段是多选列表框,需要在加载时突出显示硬编码列表中的相应列表项.
使用C#,如何根据数据库字段中逗号分隔的字符串填充多选列表框 - 选择适当的项目?我已经研究了一些涉及循环的解决方案,但我无法让他们使用我有限的C#技能组.
在我遇到困难之前,这就是我现在所拥有的一切.您会看到它没有考虑字符串中的多个值.是否有像"包含"这样的函数,我可以查看该值是否匹配?我仍然缺少一些(可能是基本的)C#逻辑和编码.
int i;
for (i = 0; i <= CATEGORYListBox.Items.Count - 1; i++)
{
if (reader["CATEGORY"].ToString() == CATEGORYListBox.Items(i).Value)
{
CATEGORYListBox.Items(i).Selected = True;
}
}
Run Code Online (Sandbox Code Playgroud)
...
<asp:ListBox ID="CATEGORYListBox" runat="server">
<asp:ListItem Value="Circulation">Circulation</asp:ListItem>
<asp:ListItem Value="Interactive Media">Interactive Media</asp:ListItem>
<asp:ListItem Value="Classified">Classified</asp:ListItem>
<asp:ListItem Value="Publishing">Publishing</asp:ListItem>
<asp:ListItem Value="Editorial">Editorial</asp:ListItem>
<asp:ListItem Value="Retail">Retail</asp:ListItem>
</asp:ListBox>
Run Code Online (Sandbox Code Playgroud)
感谢大家.
这个版本没有公共刷新方法,我似乎无法找到一种方法.
我需要按值手动选择项目.
这是我正在使用的版本的链接,我无法更改版本.http://quasipartikel.at/multiselect/
我是jquery的新手,非常感谢任何帮助.虽然这个小部件太棒了:)
非常感谢,本.
我有一个应用程序,我有很多实例将单个html选择的用户选择传递给表单字段没有问题,但我在多选案例中努力做同样的事情.似乎该JQuery.val()函数正在创建一个正确的数据数组,但我在服务器上的formfield显示一个空字符串.我继承了这个应用程序,并且在某种程度上是一个菜鸟.
相关的javascript函数是
$('.exemptionfield').change(function() {
var exemptionfield = $(this)
$.ajax({
url: '/form/ASubstanceExemption',
type: 'POST',
data: {
sclId: $('#sclId').val(),
substance: exemptionfield.attr('id'),
exemption: exemptionfield.val()
}
})
})
Run Code Online (Sandbox Code Playgroud)
表格看起来像
class ASubstanceExemption(forms.Form):
buttonTitle = 'submit'
title = 'not used'
sclId = forms.IntegerField()
substance = forms.CharField()
exemption = forms.MultipleChoiceField(required=False,
choices=kExemptions)
def handle(self, *args, **kwargs):
sclId = self.cleaned_data['sclId']
substance = self.cleaned_data['substance']
exemption = self.cleaned_data['exemption']
print exemption
etc...
Run Code Online (Sandbox Code Playgroud)
HTML选择看起来像
<select multiple size="5" class="exemptionfield" id="Lead/lead compounds">
<option value="1(a)">
1(a)
</option>
<option value="1(b)">
1(b)
</option>
<option value="1(c)">
1(c) …Run Code Online (Sandbox Code Playgroud) 我正在使用https://github.com/isteven/angular-multi-select 中的angular-multi-select 下拉列表。现在我想在量角器中编写测试用例。
<div ng-show="!attribute.isMultivalued && page != 'view'"
class="select-group"
multi-select
input-model="typesDataDup"
output-model="attribute.types"
button-label="typeName"
item-label="typeName"
tick-property="ticked"
selection-mode="single"
helper-elements="filter"
is-disabled = "page == 'view'">
</div>
Run Code Online (Sandbox Code Playgroud)
我无法使用模型发送数据,因为这里我们没有提到 ng-model。
有人可以帮我写测试用例吗?
Bootstrap multisleect 有全选选项(例如这里)。这可以实现多选吗?
我知道我可以通过以下方式使用多重编辑:
但我真正想要的是能够多选到行尾。是否有任何解决方法来实现这一点,而不是使用 ALT+SHIFT 并通过千/百万行反复按 PGDN 键?
[(ngModel)] 不能在表单标签内工作
当我使用 Multi Select Outside Form 标签时,可以正常选择 All 和 Deselect All 功能
但是我当我把它放在表格里面时它工作选择所有值
<form [formGroup]="roleForm">
<mat-form-field class="example-full-width">
<mat-select placeholder="Select Role Type" formControlName="roleType" (selectionChange)="roleTypeSelect($event.value)">
<mat-option *ngFor="let role of roleTypeList" [value]="role.roleTypeId">
{{role.roleTypeName}}
</mat-option>
</mat-select>
</mat-form-field> <!-- Multi Select Mat Start -->
<mat-form-field class="example-full-width">
<mat-select placeholder="Select Privileges" class="filter-select" [formControl]="selectedItems" [compareWith]="equals" multiple
#privilegeSelect="ngModel">
<mat-option disabled="disabled" class="filter-option">
<button mat-raised-button class="mat-primary fill text-sm" (click)="selectAll(privilegeSelect, dropdownList)">
Select All
</button>
<button mat-raised-button class="mat-primary fill text-sm eta-margin-all" (click)="deselectAll(privilegeSelect)">
Deselect All
</button>
</mat-option>
<mat-option *ngFor="let privilege of dropdownList" [value]="privilege">{{privilege.itemName}}</mat-option> …Run Code Online (Sandbox Code Playgroud) 我正在尝试使用 Material 在 Angular 中实现多选。
当页面在编辑模式下打开时,某些类型应该在多选中选择为默认值,但在我的情况下不起作用。
下面是 HTML:
<mat-form-field >
<mat-select placeholder="DocTypes" [(value)]="selectedDocType" formControlName="docTypes" multiple>
<mat-option *ngFor="let doc of docs" [value]="doc.name">{{doc.name}}</mat-option>
</mat-select>
</mat-form-field>
Run Code Online (Sandbox Code Playgroud)
我正在填写 SelectedDocType 如下:
selectedDocType: string[] = new Array();
resp.forEach(x => {
this.selectedDocType.push(x.name);
});
Run Code Online (Sandbox Code Playgroud)
这里 resp 包含正确的文档类型。比如简历。
奇怪的是,当我将 selectedDocType 设置为如下所示时,它就可以工作了:
this.selectedDocType = ["CV"];
Run Code Online (Sandbox Code Playgroud)
但是当我按上面提到的 for each 时,它不起作用。他们两个在数组中都有 1 个值。
我究竟做错了什么?
更新:文档格式如下:
export interface DocTypes{
id: string;
name: string;
}
Run Code Online (Sandbox Code Playgroud) 如何清除fSelect单击事件中的多选下拉列表,这是一个示例 通过单击清除按钮它应该删除所有选定的值。
(function($) {
$(function() {
$('.my-select-box').fSelect();
$('#ClearSelect').click(function(){
$("#fselectMulti option:selected").removeAttr("selected");
})
});
})(jQuery);Run Code Online (Sandbox Code Playgroud)
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<link href="https://facetwp.com/wp-content/plugins/facetwp/assets/vendor/fSelect/fSelect.css" rel="stylesheet"/>
<script src="https://facetwp.com/wp-content/plugins/facetwp/assets/vendor/fSelect/fSelect.js"></script>
<select id="fselectMulti" class="my-select-box" multiple="multiple">
<optgroup label="Northeast">
<option selected value="me">Maine</option>
<option selected value="ny">New York</option>
<option value="nj">New Jersey</option>
<option value="vt">Vermont</option>
</optgroup>
<optgroup label="Southwest">
<option value="az">Arizona</option>
<option selected value="nm">New Mexico</option>
<option value="ca">California</option>
<option value="nv">Nevada</option>
</optgroup>
</select>
<button id="ClearSelect">Clear</button>Run Code Online (Sandbox Code Playgroud)
我正在尝试在 PyQt 5-python 中实现如下图所示的内容,我不一定要查找向上/向下按钮,但是使用 OK 按钮来获取所选项目的列表。我没有看到为 pyqt5 实现的任何类似示例,我想知道是否有人有一些指导?
multi-select ×10
jquery ×3
angular ×2
javascript ×2
angularjs ×1
asp.net ×1
c# ×1
database ×1
django ×1
django-forms ×1
fselect ×1
listbox ×1
listview ×1
materialize ×1
notepad++ ×1
protractor ×1
pyqt5 ×1
python ×1
select ×1
testing ×1