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

  • Home
  • SEARCH
  • 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 9047891
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T12:00:49+00:00 2026-06-16T12:00:49+00:00

I have a view where I make take information from a row in Jqgrid

  • 0

I have a view where I make take information from a row in Jqgrid and then make an ajax call to the controller using that info as parameteres. The parameters are being passed to the controller however when the it does not perform the action that I desire, I am trying to create a csv file.

View:

    function sendParams() {
    var selId = jQuery("#list").jqGrid('getGridParam','selrow');
    var data = jQuery("#list").jqGrid('getRowData',selId);

        $.ajax({
        type: "GET",
        url: '@Url.Action("ExportToExcel","Home")',
        data: {sidx: 'abcd', sord: 'desc', page:1, rows: 100, id: data.selId, rid: data.id, process: data.process, detail_table: data.detail_table, jobGroup: @Html.Raw(Json.Encode(@ViewBag.jobGroup)), date: @Html.Raw(Json.Encode(@ViewBag.DateSelected))},
        contentType: "application/json; charset=utf-8",

        });
}   


      <button onclick="function sendParams()">Export</button>

Controller

    public ContentResult ExportToExcel(String sidx, String sord, int page, int rows, String id, String process, String detail_table, String jobgroup, String date)
    {


            var sw = new StringWriter();

            List<myModel alist = DAL.ExportExcelConn2.SelectGridItems(sidx, sord, page, rows, rid, process, detail_table, jobgroup, date);

            foreach (var item in alist)
            {

                sw.WriteLine(String.Format("{0}, {1},{2},{3},{4},{5},{6},{7},{8},{9},{10},{11},{12},{13},{14},{15},{16}", item.abc, item.sstuff, item.stuff2, item.stuff3, item.stuff4, item.stuff5, item.stuff6, item.stuff7, item.stuff8, item.stuff9, item.stuff10, item.stuff11, item.stuff12, item.stuff13, item.stuff14, item.stuff15, item.stuff16));

            }


            Response.Clear();
            Response.AddHeader("Content-Disposition", "attachment; filename=Exportabc" + DateTime.Now + ".csv");
            Response.ContentType = "text/csv";
            Response.Write(sw);
            Response.End();


        return Content("Test");


    }
  • 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-16T12:00:50+00:00Added an answer on June 16, 2026 at 12:00 pm

    If you use $.ajax call you can process the server response inside of success or error callback. What you really need in case of returning CSV or Excel data is setting of new window.location.

    For example

     window.location = '@Url.Action("ExportToExcel","Home")' + '?' +
        $.param({
            sidx: 'abcd',
            sord: 'desc',
            page:1,
            rows: 100,
            id: data.selId,
            ... // -- all other options
        });
    

    In the case web browser will automatically open the program on the computer (like Excel).

    I recommend you additionally to read the answer which contain ASP.NET MVC Project which export data to Excel (real XLSX file).

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

Sidebar

Related Questions

I have a view that has a column to make it sortable. When clicking
I have a MS SQL view that I want to make available as a
I have a MySQL database where I am storing information that is entered from
I have a modal view controller that creates core data changes in it's own
I am using navigation controller to move from one view to another ... i
I have a login view controller which make a request to the server for
I have a view controller which will make a server request. I have put
i have small query as follows: If i will make view state property of
I have 4 image views on a view.I want to make the 4 images
I am looking to make a Master Detail View. I have two tables tbFamily

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.