Click here to Skip to main content
15,885,216 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Can anyone help me how to pass list of integer values from view to mvc controller using url.action ??

What I have tried:

I don't know anything about it
Posted
Updated 24-Oct-21 23:50pm

1 solution

FWIW – you don’t need the bracket notation if you’re submitting simple types to the server. That is, if your request contains key=foo&key=bar&key=baz, we’ll correctly bind that to an IEnumerable<T>, IList<T>, ICollection<T>, T[], Collection<T>, or List<T>.
Unfortunately, there's no simple way to build a URL like that using the Url.Action helpers. Instead, you'd need to build your own query-string.

For example:
Razor
<a href="@Url.Action("YourAction", "YourController")?id=@string.Join("&id=", yourListOfIntegers)">Click me</a>
 
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