简体   繁体   English

选择DropDownListFor时是否可以发布更多值(例如ViewBag或Viewmodel值)?

[英]Can I post back more values (e.g. ViewBag or Viewmodel values) when a DropDownListFor is selected?

I have a DropDownListFor that is working fine. 我有一个DropDownListFor正常工作。 It's posting back the correct value as selected by the user. 它回发了用户选择的正确值。 I'm trying to figure out if some of the Viewbag settings in the View can also be posted back to the controller (as query string items eg localhost:44346/Donation/IndexManage?Page=3&PageSize=20&SortOrder=ID). 我试图弄清楚视图中的某些Viewbag设置是否也可以发布回控制器(例如查询字符串项,例如localhost:44346 / Donation / IndexManage?Page = 3&PageSize = 20&SortOrder = ID)。

Using javascript I am triggering the form to submit on change of the DDL items ... all working OK. 使用javascript,我触发了DDL项更改时提交的表单...一切正常。 Any help would be appreciated. 任何帮助,将不胜感激。

@using (Html.BeginForm("IndexManage", "Donation", FormMethod.Get, new { id = "DDL_PageSize" }))
{
    <div id="Paging">

        Records to Display:

        @Html.DropDownListFor(  
            // 1. Store selected value in Model.Donation.WalkerID;
            // when page is rendered after postback,
            // take selected value from Model.Donation.WalkerID.
            model => model.PageSize,

            // 2. Take list of values from Model.Walkers
            Model.PageSizeDDL,

            // 3. Text for the first 'default' option
            @Model.DisplayPageSizeDDL,

            //4. A class name to assign to <select> tag
            new { @class = "form-control form-control-md g-py-13 pr-0"})

    </div>
}

<script type="text/javascript">
    $(function () {
        $("#PageSize").change(function () {
            alert("Triggered by DDL");
            $("#DDL_PageSize").submit();
        });
    });
</script>

尝试这个

@using (Html.BeginForm("ActionName","ControllerName", FormMethod.Get, new { param1 = "param1", param2 = "param2 " }))

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Lambda-在复选框列表中选择符合所有选定值的所有项目 - Lambda - select all items which meets ALL selected values in e.g. checkboxlist 当Jquery更改DropDownListFor的选定值时,如何将DropDownListFor的选定值绑定到视图模型中的selectedId属性 - How to bind selected value of a DropDownListFor to selectedId property in viewmodel, when selected value of DropDownListFor is changed by Jquery 当我使用 DropDownListFor 时,我可以显示所选项目但 Id 不正确 - When I use DropDownListFor, I can display the selected item but the Id is not true 如何在保存 Telerik 上传时将 Telerik DropDownListFor 选定值获取到 controller - How to get Telerik DropDownListFor selected values to controller on save of Telerik Upload 填充值下拉列表 - dropdownlistfor fill values 当我尝试将图像插入数据库时,它只显示路径,例如“http://127.0.0.1:8000/storage/images” - When I'm trying to insert the image in the database, it just shows me the path only, e.g. 'http://127.0.0.1:8000/storage/images' 当在下拉列表中选择值时,MVC Post值使用ajax - MVC Post values using ajax when value selected in dropdownlist 是否已从控制器准备好ViewBag值? - Ready ViewBag values from controller? 无处不在的HTML.DropDownList即使我可以动态查询选定的值也无法选择默认值 - Ubiquitous HTML.DropDownListFor not selecting a default, even though I can query the selected value dynamically 为什么我的DropDownListFor在POST时填充我的id属性? - Why wont my DropDownListFor populate my id property when I POST?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM