This question is locked. New answers and comments are not allowed.
Hello,
I'm getting the following error when I click on a header of my grid (to sort by that column):
Debugging through, it is going to the controller fine and returning the data as expected, however this error is occurring somewhere along the way. I am rendering the grid inside a .ascx file which is being loaded by an Ajax load (jquery.load()) into a #div location. The parent file is also a .ascx file. This error is confusing me because the grid appears fine when it first loads. It's only on the postback to update data that it encounters the error. I don't get why the grid even cares whether it's a viewpage or viewuser control. It should only be interested in the data, right?
Here's what I'm using:
MVC v1
c#
IE 8 and Firefox 3.5.8 browsers (error occurs on both)
jquery 1.4.2
Teleric mvc Q1 2010
MS XP Pro and Vista Ultimate (error occurs on both)
Here is the view (i've commented out some stuff since grouping and filtering cause different errors which i'll get to later). The file is called ProjectDataAnalyzer.ascx:
And here are the relevant methods from the controller. The first method is called by the initial ajax load.
Thank you for any help,
Chris
I'm getting the following error when I click on a header of my grid (to sort by that column):
Exception Details: </b>System.InvalidOperationException: A ViewUserControl can only beused inside
pages that derive from ViewPage
Debugging through, it is going to the controller fine and returning the data as expected, however this error is occurring somewhere along the way. I am rendering the grid inside a .ascx file which is being loaded by an Ajax load (jquery.load()) into a #div location. The parent file is also a .ascx file. This error is confusing me because the grid appears fine when it first loads. It's only on the postback to update data that it encounters the error. I don't get why the grid even cares whether it's a viewpage or viewuser control. It should only be interested in the data, right?
Here's what I'm using:
MVC v1
c#
IE 8 and Firefox 3.5.8 browsers (error occurs on both)
jquery 1.4.2
Teleric mvc Q1 2010
MS XP Pro and Vista Ultimate (error occurs on both)
Here is the view (i've commented out some stuff since grouping and filtering cause different errors which i'll get to later). The file is called ProjectDataAnalyzer.ascx:
| <%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<IEnumerable<JetSoft.Jet.Controllers.Project.ProjectTransactionsViewModel>>" %> |
| <%@ Import Namespace="JetSoft.Jet.Controllers.Project"%> |
| <% Html.Telerik().Grid<ProjectTransactionsViewModel>(Model) |
| .Name("Grid") |
| .Columns(columns => |
| { |
| columns.Bound(o => o.ResourceName).Title("Resource Name").Width(120); |
| columns.Bound(o => o.ResourceClass).Title("Class").Width(120); |
| columns.Bound(o => o.Quantity).Width(80); |
| columns.Bound(o => o.RateUnit).Width(50); |
| columns.Bound(o => o.Task).Title("Task").Width(120); |
| columns.Bound(o => o.EffectiveDate).Format("{0:MM/dd/yyyy}").Width(80).Title("Work Date"); |
| columns.Bound(o => o.CostValue).Title("Cost"); |
| columns.Bound(o => o.BillableValue).Title("Billable"); |
| columns.Bound(o => o.Margin).Title("Margin").Format("%"); |
| }) |
| // .Ajax(ajax => ajax.Action("ProjectTransactions", "Project")) |
| // .Groupable() |
| .DataBinding(dataBinding => dataBinding.Ajax().Select("UpdateGrid", "Project")) |
| .Scrollable() |
| .Sortable() |
| // .Filterable() |
| .Render(); |
| %> |
And here are the relevant methods from the controller. The first method is called by the initial ajax load.
| public ActionResult ProjectDataAnalyzer() |
| { |
| return PartialView("ProjectDataAnalyzer", ProjectTransactions()); |
| } |
| private IEnumerable<ProjectTransactionsViewModel> ProjectTransactions() |
| { |
| int projectId = Int32.Parse(Request.Params.Get("ProjectId")); |
| var today = DateTime.Today; |
| var aYearAgo = new DateTime(today.Year - 1, today.Month - 1, today.Day); |
| IEnumerable<ProjectTransactionsViewModel> transactions = ProjectEntity.ProjectTransactions(projectId, aYearAgo, today); |
| return transactions; |
| } |
| [GridAction] |
| public ActionResult UpdateGrid() |
| { |
| IEnumerable<ProjectTransactionsViewModel> transactions = ProjectTransactions(); |
| return this.PartialView(new GridModel(transactions)); |
| } |
Thank you for any help,
Chris