0

For my custom paging I want to add an array of int's to the querysting (filtering)

this my code in the view:

            @foreach(var page in ViewBag.pagination){
                 string index = Convert.ToString(page.index);
                 if (page.skills != null) 
                 {
                    <li>@Html.ActionLink(index, "index", "vacancy", new { skills= string.Join("&skills=", page.skills)}, null)</li>
                 }
                 else
                 {
                    <li>@Html.ActionLink(index, "index", "vacancy", new {page = page.index}, null)</li>
                 }
            }

this line

<li>@Html.ActionLink(index, "index", "vacancy", new { skills= string.Join("&skills=", page.skills)}, null)</li>

results in: ?skills=1%26skills%3D2

but how can i change the querystring into this: ?skills=1&skills=2 ?

1 Answer 1

1

You can use this

<li>@Html.ActionLink(index, "index", "vacancy")+"?"+string.Join("&", page.skills.Select(s=>"skills="+s)))</li>
Sign up to request clarification or add additional context in comments.

1 Comment

Although this is almost certainly a working, stphn may be better served by building a route value dictionary to handle the array, IMHO.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.