DiPix DiPix - 2 years ago 88
Javascript Question

How to pass LIST to view as JSON in MVC asp.net

I need to pass this list to my view:
enter image description here

But in this format:

"data": [
"FIRST_NAME": "Robert",
"LAST_NAME": "Meczybula",
"ID": 12421

Answer Source

Basically you want to transform your list to the desired data contract. Linq is good for this:

var transform = new
        data = data.Select(x => 
            new {

Then just serialize and return the transform object.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download