views:

191

answers:

1

Hi, I have a list view for one of my controller's index action. In that View's source, I have added the following code to the for loop present inside the source of View.

<%= Html.ActionLink("Select", "ActionName", new object { controller = "Home", action = "ActionName", iID1 = Convert.ToInt32(ViewData["ID"].ToString()), iID2 = Convert.ToInt32(item.Id) })%>

Thus i will get a link named "Select" against each of the entry present on this View. But I can't pass the parameters to my controller action using above code.

How can i do this - passing parameters to Controller-Action using action link Click?

Regards, Kapil

+1  A: 

This will work for your case:

<%=Html.ActionLink("Select","ActionName","Home",new { iID1 = Convert.ToInt32(ViewData["ID"].ToString()), iID2 = Convert.ToInt32(item.Id) },null)%>

null is the httml attribute you want to set for the link like new {class="CSSClassforthelink"}

tuanvt