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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T03:41:14+00:00 2026-06-08T03:41:14+00:00

I have MVC2 view in which there is a grid and image button. When

  • 0

I have MVC2 view in which there is a grid and image button. When image button is clicked, it will pass the data of grid’s currentPage, filter and orderBy fields … to another controller. The code is,

<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<MaintenanceEditableViewModel>" %>

"Image button"
<a href="<%: Url.Action("ExportToExcel", "ExportExcelButton", new { resourceId = ViewData["resourceId"], pagenum = ViewData["page"], orderBy = ViewData["orderBy"], filter = ViewData["filter"] }) %>">
<img src='<%: Url.Content("~/Content/Images/ExportExcelButton.gif") %>' /></a>

"Grid"
<%= Html.Telerik().Grid<MaintenanceAthletesResultsViewModel>()
.Name("Grid")
.TableHtmlAttributes(new { style = "font-size:8pt;" })
.HtmlAttributes(new { style = "height:335px" })
.DataKeys(k => k.Add(k2 => k2.ResultID))
.DataBinding(dataBinding => dataBinding.Ajax()
.Select("AthletesResultsAjax", "Maintenance")
...

"Action to initialize the grid in Maintenance controller"
public ActionResult AthletesResults(string id, bool editable)
{
ViewData["resourceId"] = id;
this._resourceBL.PopulateMaintenanceResourcesViewData(id, this.SelectedSport());

MaintenanceEditableViewModel model = new MaintenanceEditableViewModel { Editable = editable };
return View(model);
}

[GridAction]
public ActionResult AthletesResultsAjax(string id, int page, string orderBy, string filter)
{
List<MaintenanceAthletesResultsViewModel> model = null;

if (!string.IsNullOrEmpty(id))
{
ViewData["page"] = page;
ViewData["orderBy"] = orderBy;
ViewData["filter"] = filter;

model = this._resourceBL.GetMaintenanceAthletesResultsViewModel(int.Parse(id));
}

return View(new GridModel(model));
}

public ActionResult ExportToExcel(string resourceId, string pagenum, string orderBy, string filter)

The strange thing is that only ViewData[“resourceId”] (set in initialization of view) is able to be passed. The 3 parameters, ViewData[“page”], ViewData[“orderBy”], ViewData[“filter”] (set in grid ajax action) can not be passed. All 3 are null in ExportToExcel and so I think they are not correctly stored in ViewData (I am not sure how to check ViewData when image button is pressed). I am confused and need help on this.

Thanks

  • 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-08T03:41:15+00:00Added an answer on June 8, 2026 at 3:41 am

    I don’t see how/where you’re sending those arguments into the AthletesResultsAjax action. The signature of the dataBinding.Ajax().Select() function you’re using only specifies the action and the controller name. How is it going to know what those values are? You need to specify a routeValues object to send the appropriate data to the controller action. If you debug the code and put a breakpoint in your ajax action, do the actual values come through? I could be quite off here but I think your problem is more on this end than on how the data is being stored in the ViewData.

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

Sidebar

Related Questions

I have an MVC2 view which is strongly bound to a model. <%@ Page
I have a form (using MVC2) which has an image-upload script, but the rules
I have a strongly type View in an ASP.NET MVC2 application in which i
I have a mvc2 application with a view like this <% using (Ajax.BeginForm(UserApprove, new
I'm using MVC2 with VS2010 I have a view that has two partial views
I have an ASP.NET MVC2 site connecting to a MySQL database via DbLinq. There
I'm building an asp.net MVC 2 app. I have a list view which lists
I have a web application which was using Asp.net MVC2 . I Upgraded it
I have following markup which is generated dynamically using C# in my asp.net MVC2
I've one more question. I have a view which is containing an add link.

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.