Click here to Skip to main content
15,892,298 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
How to send the selected drop down value to web grid page size.Please help
@model IEnumerable<hrms_dl.zbs_hr_route>
@{
Layout = null;
}


@{



var grid = new WebGrid(Model, rowsPerPage:10, ajaxUpdateContainerId: "myGrid", canSort: true);
@grid.GetHtml(columns: grid.Columns(
//grid.Column("RT_ID", header: string.Format("ROUTE ID", grid.SortColumn == "RT_ID" ? grid.SortDirection == SortDirection.Ascending ? "▼" : "▲" : "▼")),
grid.Column("RT_ID", "ROUTE ID"),
grid.Column("RT_NAME", "ROUTE NAME"),
grid.Column(format: (item) => Html.ActionLink("Edit", "Edit", new { id = item.RT_ID, area = "EIM" }, null)),
grid.Column(format: (item) => Html.ActionLink("Details", "Details", new { id = item.RT_ID, area = "EIM" }, null))
));


}

------------------------------------------------------------------------------------------------------

control
------------------------------------------------------------------------------------------------------

//define values for drop down
C#
public static SelectList PageSizeSelectList()
{
    var pageSizes = new List<string> { "1", "2", "5", "10", "100" };
    return new SelectList(pageSizes, "Value");
}

-------------------------------------------------------------------------------------------------------
view
-------------------------------------------------------------------------------------------------------

//take the selected value
XML
<script>

    $(function () {
        $('#pageSizes').change(function () {
            var selectedValue = $(this).val();
            $('#pageSizes').val(selectedValue);
            //alert(selectedValue);
        });
    });


</script>




//drop down

<label>Page Size</label>

@Html.DropDownList("pageSizes", HRMS.Areas.EIM.Controllers.RouteController.PageSizeSelectList(), new { onchange = "onPageSizeChange()" }) rows per page




Posted
Updated 12-Sep-12 18:42pm
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900