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 698339
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T03:15:50+00:00 2026-05-14T03:15:50+00:00

If I have a list of objects IEnumerable<MyType> myTypes; Is it possible for me

  • 0

If I have a list of objects

IEnumerable<MyType> myTypes;

Is it possible for me to return this to the client as JSON

return Json(myTypes);

and if so, is it possible for me to convert this (now JSON format) list to a <table> when it gets to the client?

Is there any jQuery plugin to do this?

The thing is, there’s loads of other stuff I need to send as JSON also, so generating a table with a PartialView and embedding that into the JSON is a extra complexity that I’d like to avoid.

  • 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-05-14T03:15:50+00:00Added an answer on May 14, 2026 at 3:15 am

    I came up with my own solution for a similar problem, I wanted to be able to display any JSON object array response into a nice table without having to hard code anything in the JavaScript so it was reusable!

    Here is what I did…

    <script type="text/javascript">
        $(document).ready(function() {
            $.ajax({
                type: "POST",
                url: "DemoSvc.asmx/GetJSONTableContents",
                contentType: "application/json; charset=utf-8",
                dataType: "json",
                data: "{}",
                success: function(res) {
                    $('#<%= DynamicGridLoading.ClientID %>').hide();
                    $('#<%= DynamicGrid.ClientID %>').append(CreateDynamicTable(res.d)).fadeIn();
                }
            });
        });
    </script>
    

    This is doing the pulling of data from the web service to the page, the important part of this code is the call to the "CreateDynamicTable()" that converts the JSON object array to a pretty HTML table. Below is the code, the output is a pretty table of HTML.

    function CreateDynamicTable(objArray) {
      var array = JSON.parse(objArray);
    
      var str = '<table class="lightPro">';
      str += '<tr>';
      for (var index in array[0]) {
        str += '<th scope="col">' + index + '</th>';
      }
      str += '</tr>';
      str += '<tbody>';
      for (var i = 0; i < array.length; i++) {
        str += (i % 2 == 0) ? '<tr class="alt">' : '<tr>';
        for (var index in array[i]) {
          str += '<td>' + array[i][index] + '</td>';
        }
        str += '</tr>';
      }
      str += '</tbody>'
      str += '</table>';
      return str;
    }
    

    I also looked for something FREE to do this, but everything I found was commercial or required hard coding column values. I did a quick blog post with additional details, screen shot and a simple VS 2008 demo. Overall, it’s working perfect for what I needed.

    Blog Article on JSON data to HTML Table

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have List objects which are shown like this: www.mysite.com/lists/123 Where 123 is the
I have a list of objects (Debtors) in this structure public class DebtorDto {
I have an IEnumerable list of objects in C#. I can use a for
i have a list of project objects: IEnumerable<Project> projects a Project class as a
I have a model that contains an IEnumerable of a list of custom objects.
I have a List/IEnumerable of objects and I'd like to perform a calculation on
I have a list of objects contained in an IEnumerable<>. I would like to
I have an IEnumerable of Lesson objects: IEnumerable<Lesson> filteredLessons I convert it to a
I have an IEnumerable that has a list of objects with ids. I want
I have 2 List objects: List<int> lst1 = new List<int>(); List<int> lst2 = new

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.