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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T00:33:32+00:00 2026-05-23T00:33:32+00:00

This is probably the dumbest question ever here on stack Overflow. But I am

  • 0

This is probably the dumbest question ever here on stack Overflow. But I am getting the weirdest results from some code that I am working with. I am trying to get jqGrid to work in my MVC 2 application.

My home controller has an action method for Index and GridData… GridData takes 4 parameters, 2 of them cannot be null so I add a defalutValue attribute with a value of one to them. The Index controller redirects to the GridData action method wich then opens up a GridData view… I don’t return the View in this function but I return a Json variable…

[Authorize(Roles="testRole")]
    public ActionResult Index(string nextButton)
    {
        ViewData["identity_Name"] = identity.Name;
        if (nextButton != null)
            return RedirectToAction("GridData");
        return View("Index");
    }

    public ViewResult windowsID()
    {
        return View();
    }

    public ActionResult GridData(string sidx, string sord, [DefaultValue(1)] int page, [DefaultValue(1)] int rows) 
    {
        var jsonData = new 
        {
            total = 1, // we'll implement later 
            page = page,
            records = 3, // implement later 
            rows = new[]    
            {
                new {id = 1, cell = new[] {"1", "-7", "Is this a good question?"}},
                new {id = 2, cell = new[] {"2", "15", "Is this a blatant ripoff?"}},
                new {id = 3, cell = new[] {"3", "23", "Why is the sky blue?"}}
            }   
        };
        return Json(jsonData, JsonRequestBehavior.AllowGet);
    }
}

Here is most of my Javascript code.

<script type="text/javascript">
jQuery(document).ready(function () {
    jQuery("#list").jqGrid({
        url: '/Home/GridData/',
        datatype: 'json',
        mtype: 'GET',
        colNames: ['Id', 'Votes', 'Title'],
        colModel: [
      { name: 'Id', index: 'Id', width: 40, align: 'left' },
      { name: 'Votes', index: 'Votes', width: 40, align: 'left' },
      { name: 'Title', index: 'Title', width: 200, align: 'left'}],
        pager: jQuery('#pager'),
        rowNum: 10,
        rowList: [5, 10, 20, 50],
        sortname: 'Id',
        sortorder: "desc",
        viewrecords: true,
        imgpath: '/scripts/themes/smoothness/images',
        caption: 'My first grid'
    });
}); 

Seems reasonable right? Why on earth would it download the page instead of redirecting to it? What on Earth could I possible be doing wrong here. Well plenty I guess, but I think I am just missing something simple.

  • 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-23T00:33:33+00:00Added an answer on May 23, 2026 at 12:33 am

    Ok. I think I figured it out. I don’t want to redirect to an action. The action returns a Json data type and that is just text so the browser is just going to attempt to download it. I want to redirect to a view… So what I did is make a helper function that returns a json data and I do redirect to the dataGrid controller. But the Json script now calls the helper function and that worked… Except for a Javascript error which I have know Idea how to solve (It is basically a formatting error so if I click past it, it will render).

    Thanks for the help anyway guys.

    Derek

    P.S here is my coded solution incase you wanted to check it out for yourself if you are having the same problem…
    jqGrid call

    jQuery(document).ready(function () {
        jQuery("#list").jqGrid({
            url: '/Home/GetData/',
            datatype: 'json',
    

    Here are my actions inside the controller.

     public JsonResult GetData(string sidx, string sord, [DefaultValue(1)] int page, [DefaultValue(3)] int row)
        {
            var jsonData = new
            {
                total = 1, // we'll implement later 
                page = page,
                records = 3, // implement later 
                rows = new[]    
                {
                    new {id = 1, cell = new[] {"1", "-7", "Is this a good question?"}},
                    new {id = 2, cell = new[] {"2", "15", "Is this a blatant ripoff?"}},
                    new {id = 3, cell = new[] {"3", "23", "Why is the sky blue?"}}
                }
            };
            return Json(jsonData, JsonRequestBehavior.AllowGet);
        }
    
        public ActionResult GridData() 
        {
            return View("GridData");
        }
    

    As you can see after I redirect to GridData(), which calls the griddata view, jqGrid then calls GetData(). GetData then returns Json data which is rendered in the view…

    If anyone has a better way to do this, please reply. But thanks for the help.

    Derek

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

Sidebar

Related Questions

This probably sounds like a really dumb question, but here goes....Web Services, what the
This is probably a silly question, but curiosity has gotten the better of me.
This is probably a really simple jQuery question, but I couldn't answer it after
This is probably a really stupid newbie-sounding question to you developer type people, but
This probably is a very very basic question but i can't seem to find
This probably sounds like a terrible idea at first glance, but here is my
This probably is one of the easiest question ever in C programming language... I
This probably might be a silly question, but what I am trying to do
I know this probably must be a newbie question, but since I don't know
this probably is a basic question, but can I do something like this: Class

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.