Quantcast
Channel: ASPNETWebStack Issue Tracker Rss Feed
Viewing all articles
Browse latest Browse all 7215

Closed Unassigned: Passing parameters to Action Method from ActionLink [1565]

$
0
0
Hi
I want to pass dropdown values to action method from ActionLink but while debugging second parameter coming properly but first one is null.
Have a look at my code.
Razor:

@Html.DropDownListFor(x => x.SelectedField, new SelectList(Model.Filter, "Id", "Name", Model.SelectedField),new { @class = "select1", style = "width:120px;" } )

@Html.DropDownListFor(x => x.SelectedYear, new SelectList(Model.ReportYears, "ID", "Name", Model.SelectedYear), new { @class = "select1", style = "width:120px;" })

@Html.ActionLink("Export to PDF", "DownloadRevenuePdfFile", "EmailReport", new { month = Model.SelectedField, year = Model.SelectedYear }, new { @class = "black" })


Controller
public void DownloadRevenuePdfFile(string month, string year)
{
//code
}

Thanks
Comments: It looks like Model.SelectedField is null when the view is rendered. It sounds like your expectation is that this property would somehow come from the drop down list. But this isn't possible as the drop down list is rendered at the same time as the action link.

Viewing all articles
Browse latest Browse all 7215

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>