Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9144085
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T10:10:58+00:00 2026-06-17T10:10:58+00:00

I am using Datatables grid in my MVC application to show the data. I’m

  • 0

I am using Datatables grid in my MVC application to show the data. I’m not getting how to convert the Var which contains the generic list to JSON which in turn will be the input for Datatables.

Here is the JSON format for Datatables:

return Json(new 
{
  aaData = new[] {
    new [] { "Trident", "Internet Explorer 4.0", "Win 95+", "4", "X" },
    new [] { "Gecko", "Firefox 1.5", "Win 98+ / OSX.2+", "1.8", "A" },
    new [] { "Webkit", "iPod Touch / iPhone", "iPod", "420.1", "A" },
  }
}, JsonRequestBehavior.AllowGet);

But the above one is hardcoded one, I’m getting generic list in runtime, how to iterate and change to JSON format like above.

Here is my code.

public void GetReport()
        {
            var ReportData = _homeService.GetReportDatafromDB();

            if (ReportData .Count > 0)
            {
               //Dont no how to convert for JSON data format here
            }
       }
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T10:11:00+00:00Added an answer on June 17, 2026 at 10:11 am

    Using the foreach syntax it will look something like this:

    var aaData = new List<string[]>();
    foreach(var l in ReportData){
        aaData.Add(new [] {l.Property1, l.Property2, l.Property3, l.Property4});
    }
    
    var thisIsYourResult = aaData.ToArray();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using Datatables grid in one of my application because it has a
I m using MVC Contrib grid in the application , i want to change
I'm using telerik mvc grid and bound my columns throuugh Data Table, I having
I'm using jquery datatables to display data inside grid. On init page load script
I have an ASP.NET MVC 3 app and I'm using jQuery DataTables as grid.
I am using datatable for displaying data in the grid, everything works fine except
I'm using webgrid to show data from my data base. The problem is that
I am using jquery.dataTables (1.8.1) to display a list of data, and I am
I'm sync my data from Grid to DataBase using really weird way : for
I'm using ASPxGridView and updating with data from DataTable which, works fine. But when

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.