I have been able to find lots of examples of adding a Dropdown list to a view but I need to add a dropdown list to a view that also has a Webgrid on it. This entails two different models and from what I see I can only have one per view.
The DDL will be filled from one model and the grid from the other.
I’m just trying to filter the displayed data in the grid with the data selected in the ddl.
Any examples or articles would be greatly appreciated.
TIA
Since you’re trying to filter the displayed data in the grid, I’d do it this way:
In the main view I’d call a
partial view. In your case the partial view will hold theDropDownListdata. Something like this:In your controller action you’d fill the
DropDownViewModelwith theDropDownListdata and would pass theDropDownViewModelto theViewBaglike this:ViewModel (DropDownViewModel.cs)
Partial View (DropDownView.cshtml)
"YourDataId"will be a parameter for the action method and will contain the value selected by the user like this: