Click here to Skip to main content
15,886,806 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
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.

HTML
@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;" })


action link =>

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


controller

C#
public void DownloadRevenuePdfFile(string month, string year)


thanks
Posted
Updated 18-Dec-13 1:24am
v3
Comments
Member 10434230 18-Dec-13 6:53am    
what is value of Model.SelectedField?
[no name] 18-Dec-13 7:22am    
month
[no name] 18-Dec-13 7:25am    
I update question to make it more informative

1 solution

Your link is calculated at compile time on the server. As such, your page needs to post back when a selection is made, to update any link. So I'd do away with the action link and instead have a method you call, which calculates the links and does a redirect, based on the current values.
 
Share this answer
 

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900