user802439
user802439

Reputation: 11

Telerik mvc grid with a dropdownlist in view

I have a dropdownlist with a submit button in my view. When I select a value in dropdownlist and hit submit button, HTTPPOST action in the controller is called and it binds data to the telerik mvc grid. Now, if I click the paging link in the grid, HTTPGET action in the controller is called and the grid is gone. How to persist the selected value of the dropdownlist and rebind data to telerik grid? Appreciate your help

Upvotes: 1

Views: 1219

Answers (1)

Atanas Korchev
Atanas Korchev

Reputation: 30671

You have two options

  1. Use Ajax binding for your grid. Then the page won't refresh.
  2. Pass the required value to the Select method of the databinding settings:

    <%= Html.Telerik().Grid()
            .DataBinding(dataBinding => dataBinding
               .Server()
               .Select("Action", "Controller", 
                  new { value = ViewData["dropDownValue"] })
            )    
    %>
    

Then you can get it from the action method:

public ActionResult Action(string value)
{
   //
}

Upvotes: 1

Related Questions