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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T17:34:29+00:00 2026-06-12T17:34:29+00:00

I have a table in my .aspx view in MVC3 project. I am using

  • 0

I have a table in my .aspx view in MVC3 project.
I am using .aspx views in MVC3 instead of Razor engine or .cshtml views.
I have the underwritten function in my jquery that gets me a JSON object from controller with some values in it.

function GetUsers() {
    $.ajax({
        url: ('/Home/GetUsers'),
        type: 'POST',
        contentType: 'application/json',
        data: JSON.stringify(),

        success: function (result) {
            alert(result.length);
            var partnersTable = $('#PartnersTable');
            partnersTable.html();

        },
        error: function () { alert("error"); }
    });
}

Now I have a table in my view

<div id = "topGrid">
    <table id="PartnersTable" style="float: left; width: 49%">
        <th style="width: 75%">Partner</th>
        <th style="width:25%">Users</th>
    </table>

This is how I am getting the JSON object. right now its just dummy data but willb e populaed from DB later

public JsonResult GetUsers()
        {
            var model = new List<UsersModel>();
            var item = new UsersModel();
            for (int i = 1; i <= 10; i++)
            {
                item.Partner = "Partner" + Convert.ToString(i);
                item.Count = i;
                model.Add(item);
            }
            return Json(model, JsonRequestBehavior.AllowGet);
        }

I need to show the data from above JSON object in my table.
how can I achieve this?

I am utterly new to MVC3 so please let me know if I have missed anything that is required to answer this question and please be as detailed as you can.

  • 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-12T17:34:31+00:00Added an answer on June 12, 2026 at 5:34 pm

    There are 2 approaches you might consider.

    1. Have your controller action directly return a partial view containing the table data so that you don’t have to do javascript templating
    2. Use JSON and do javascript templating

    Let’s see the first approach:

    public ActionResult GetUsers()
    {
        var model = new List<UsersModel>();
        for (int i = 1; i <= 10; i++)
        {
            var item = new UsersModel();
            item.Partner = "Partner" + Convert.ToString(i);
            item.Count = i;
            model.Add(item);
        }
        return PartialView(model);
    }
    

    Next you will have a corresponding partial view that will contain the respective section of the table:

    <%@ Control 
        Language="C#" 
        Inherits="System.Web.Mvc.ViewUserControl<IEnumerable<MvcApplication1.Models.UsersModel>>" %>
    <% foreach (var user in Model) { %>
        <tr>
            <td><%: user.Partner %></td>
            <td><%: user.Count %></td>
        </tr>
    <% } %>
    

    and then inside your main view you will have the table:

    <table id="PartnersTable" style="float: left; width: 49%" data-url="<%= Url.Action("GetUsers", "Home") %>">
        <thead>
            <tr>
                <th style="width: 75%">Partner</th>
                <th style="width:25%">Users</th>
            </tr>
        </thead>
        <tbody>
        </tbody>
    </table>
    

    and finally use AJAX to populate the body of the table:

    var table = $('#PartnersTable');
    $.ajax({
        url: table.data('url'),
        type: 'GET',
        cache: false,
        context: table,
        success: function (result) {
            this.html(result);
        },
        error: function () { alert("error"); }
    });
    

    Now let’s take a look at the second approach which consists into having the controller action return JSON and build the HTML template of the table manually:

    public ActionResult GetUsers()
    {
        var model = new List<UsersModel>();
        for (int i = 1; i <= 10; i++)
        {
            var item = new UsersModel();
            item.Partner = "Partner" + Convert.ToString(i);
            item.Count = i;
            model.Add(item);
        }
        return Json(users, JsonRequestBehavior.AllowGet);
    }
    

    and then:

    var table = $('#PartnersTable');
    $.ajax({
        url: datble.data('url'),
        type: 'GET',
        cache: false,
        context: table,
        success: function (users) {
            var tableBody = this.find('tbody');
            tableBody.empty();
            $.each(users, function(index, user) {
                $('<tr/>', {
                    html: $('<td/>', {
                        html: user.Partner
                    }).after($('<td/>', {
                        html: user.Count
                    }))
                }).appendTo(tableBody);
            });
        },
        error: function () { alert("error"); }
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a MVC project. The views are aspx. I created a view split
my application is MVC3 using ASPX views. I have two pages, create and Edit,
I am trying to add a table in aspx page and need to have
I have table View with grouped style with three sections. Get information from dictionary
I have an aspx web page contains jquery mobile, I don't know why, whenever
I am making a GUI in aspx using a grid view for a database.
I have table with around 70 000 rows. There is 6000 rows that i
I have table in which I am inserting rows for employee but next time
I have table and this table contain result column with some entries. I just
I have table with 300 000 records (MyISAM). I get record from this table

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.