1

can i pass an Int Array from Ajax.ActionLink (from my View) to Controller as a parameter

this is my view


@{
int [] IDArray = ViewBag.AllIds;
}

 @Ajax.ActionLink("send", "SendtoSS", new { id= IDArray }, new AjaxOptions
{
OnBegin = "Routing",
UpdateTargetId = "dialog-model",
InsertionMode = InsertionMode.Replace
}, new { @class = "button" })

In my Controller

public ActionResult SendtoSS(int[] ID)
    {
}
3
  • Where is IDArray defined? And are you aware you have a closing square bracket but no opening one? Commented Nov 15, 2011 at 21:55
  • I have my array in the View, Please see the question i have modified with more details. when i try this my ActionResult function in Controller received null value. but when i insert break point in my View and check that Ajax link is have IDArray with values Commented Nov 15, 2011 at 22:04
  • More details: on my action like is rendered as this localhost:80/SendtoSS?ID=System.Int32%5B%5D Commented Nov 15, 2011 at 22:06

1 Answer 1

1

Since I was not able to find a solution to pass an array. what i did was, in my view i have converted my Array of IDs to a String with a coma for each ID and in my controller i receive string parameter and convert back to array. this has solved my problem for now.

But i would like to know if we can pass an array as a parameter through action link

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.