Deva
Deva

Reputation: 139

How to make rows per page value as dynamic one in MVC3 Web Grid?

Hi ..,

Can anyone tell me the solution for assigning Dropdown selected value as rowsperpage value in MVC3 WebGrid. how can i do this. Any help can be appreciated.

Upvotes: 1

Views: 2421

Answers (1)

Garrett Fogerlie
Garrett Fogerlie

Reputation: 4458

In your controller:

public ActionResult Index(int rowsperpage = 20)
{
    // Logic to take and skip whatever
}

In your view:

@using(Html.BeginForm("Index", "Home"))
{
    <select id="rowsperpage" name="rowsperpage">
        <option value="10">10</option>
        <option selected="selected" value="20">20</option>
        <option value="50">50</option>
    </select>
    <input type="submit" value="Update" />
}

To give you a better idea of creating drop down lists with the html helper, see How to fill dropdown list statically in MVC3

Upvotes: 3

Related Questions