0

So I pass in my model to my view. The model has a list of records that have certain fields, one of the fields is a List of type string that holds numerous string values (ListHoldingString). I foreach through my model into a table. When I click the row I want to be able to pass the "List of type string that holds numerous string values" thats in the first column to a new controller where I can then use it to do other stuff.

I did try it with ajax but I couldnt retrieve the list.

I dont know how I can achieve this, has anyone got any ideas? Here is my code so far.

            <tbody>
                @foreach (var n in Model.ModelList)
                {
                    <tr>
                        <td class="hidden">@n.ListHoldingString</td>
                    </tr>
                }
            </tbody>

If no one has a solution, would a viable option be to change the list to a string thats comma delimited and post it a controller than does what it needs to do and need pass than on to another controller that displays the information?

Bad Dub
  • 1,503
  • 2
  • 22
  • 52
  • I dont think that helps me – Bad Dub Jan 17 '16 at 00:33
  • A more typical pattern is to pass the ID of the ModelList object selected, then hydrate your next page's model with the list of strings. Populating all the lists when you're not going to display them isn't a great use of bandwidth anyway. Is there a reason you can't just pass the ID? Are you using a database? – Colorado Matt Jan 17 '16 at 00:56
  • The records being shown are a series of matches, each series contains a list of the match ids that are in that series. So when I click that series row in the table I want to have all the match ids that are part of the series. So I need to be able to pass that whole list of ids. The ids are GUID converted to string – Bad Dub Jan 17 '16 at 00:59
  • Then I'd recommend posting a simple json collection of GUIDs to an action in this other controller. I would use jquery .ajax to do so. You mention you already tried that. If you can't get it to work update your question with what you've tried and we can help get you rolling. Here's something to get you started: http://stackoverflow.com/questions/309115/how-can-i-post-an-array-of-string-to-asp-net-mvc-controller-without-a-form – Colorado Matt Jan 17 '16 at 01:21

0 Answers0