Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: MVC3
How to send the selected drop down value to web grid page size.Please help
@model IEnumerable
@{
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
public static SelectList PageSizeSelectList()
{
    var pageSizes = new List<string> { "1", "2", "5", "10", "100" };
    return new SelectList(pageSizes, "Value");
}
-------------------------------------------------------------------------------------------------------
view
-------------------------------------------------------------------------------------------------------
 
//take the selected value
<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 28-Aug-12 19:47pm
Edited 12-Sep-12 19:42pm
v2

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

  Print Answers RSS
0 OriginalGriff 270
1 Sergey Alexandrovich Kryukov 185
2 BillWoodruff 173
3 CPallini 155
4 Kamal Rocks 144
0 OriginalGriff 5,655
1 DamithSL 4,506
2 Maciej Los 3,997
3 Kornfeld Eliyahu Peter 3,480
4 Sergey Alexandrovich Kryukov 3,180


Advertise | Privacy | Mobile
Web03 | 2.8.141216.1 | Last Updated 13 Sep 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100