0

在我的页面上,我在 ASP 页面上有一系列带有这种编码的 jQuery DropDowns(有些稍有改动,但不相关):

jQuery(document).ready(function () {
    jQuery(function () {
    jQuery("#UCStyle1 select").multiselect({
        header: true,
        height: 175,
        minWidth: 240,
        size: 3,
        classes: '',
        checkAllText: 'Check all',
        uncheckAllText: 'Uncheck all',
        noneSelectedText: '0 Selected',
        selectedText: '# selected',
        selectedList: 0,
        show: null,
        hide: null,
        autoOpen: false,
        multiple: true,
        position: {},
        appendTo: "body"
    });
    });

在代码隐藏中,如果我想在页面加载时在其中一个下拉列表中选择一个值,我可以这样做:

sCountry.SelectedValue = "USA";

如果我想选择多选中的所有值,我该怎么做?

4

2 回答 2

0

从小部件的源代码来看,您似乎会在页面加载时添加它。

$(document).ready(function () {
    $(function () {
        $("#UCStyle1 select").multiselect({
            header: true,
            height: 175,
            minWidth: 240,
            size: 3,
            classes: '',
            checkAllText: 'Check all',
            uncheckAllText: 'Uncheck all',
            noneSelectedText: '0 Selected',
            selectedText: '# selected',
            selectedList: 0,
            show: null,
            hide: null,
            autoOpen: false,
            multiple: true,
            position: {},
            appendTo: "body"
        }).checkAll();
    });
});
于 2016-01-22T00:42:38.430 回答
0

我发现了一种解决方案(以防有人停下来寻找答案):

foreach (ListItem li in sCountry.Items)
{
    li.Selected = true;
}

仍然希望有一些更优雅/单线的方式来做到这一点,但现在这可行。

于 2016-01-22T01:01:11.477 回答