This question is locked. New answers and comments are not allowed.
Hi,
We are trying to bind List<DataRow> to MVC grid with ajax binding but unable to do so. We are getting following error;
Sample.Aspx as follows;
Model as follows;
An last one, Controller as follows;
Any help would be greatly appreciated.
Thank you.
We are trying to bind List<DataRow> to MVC grid with ajax binding but unable to do so. We are getting following error;
The model item passed into the dictionary is of type 'System.Collections.Generic.List`1[System.Data.DataRow]', but this dictionary requires a model item of type 'messagemarketer.com.ph.report.action.BounceDetailList'.
Sample.Aspx as follows;
<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/ReportMaster.Master" Inherits="System.Web.Mvc.ViewPage<messagemarketer.com.ph.report.action.BounceDetailList>" %><asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server"> Sample</asp:Content><asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server"> <%: Html.Telerik().Grid(Model.BounceList) .Name("GridBounceList") .DataBinding(db => db.Ajax().Select("_BindBounceList", "Report")) .Pageable(paging => paging.PageSize(20).Style(GridPagerStyles.PageInput | GridPagerStyles.Numeric).Position(GridPagerPosition.Bottom)) .Sortable(sorting => sorting.SortMode(GridSortMode.MultipleColumn)) .Filterable()%></asp:Content>Model as follows;
using System;using System.Collections.Generic;using System.Linq;using System.Web;using messagemarketer.com.ph.common.basedobjects;using messagemarketer.com.domain.Service.Interface;using messagemarketer.com.domain.Service.Reports.Bulletin.Email.ReportItems;using messagemarketer.com.domain.Data;using System.Data;namespace messagemarketer.com.ph.report.action{ public class BounceDetailList : IReport { private IService _service; public IService Service { set { this._service = value; } } public Guid ActiveBulletin { get; set; } public DateTime? StartDate { get; set; } public DateTime? EndDate { get; set; } public String Action { get; set; } public String BounceType { get; set; } public List<DataRow> BounceList { get; set; } public Int32 DataCount { get; set; } public Object Run() { switch (BounceType) { case "soft": if (Action == "ready") BounceList = ((IBulletinService)_service).Reports.GetBulletinReports(ActiveBulletin).EmailReports.SoftBounceListInActiveData.List; else if (Action == "done") BounceList = ((IBulletinService)_service).Reports.GetBulletinReports(ActiveBulletin).EmailReports.SoftBounceListInPassiveData.List; break; case "hard": if (Action == "ready") BounceList = ((IBulletinService)_service).Reports.GetBulletinReports(ActiveBulletin).EmailReports.HardBounceListInActiveData.List; else if (Action == "done") BounceList = ((IBulletinService)_service).Reports.GetBulletinReports(ActiveBulletin).EmailReports.HardBounceListInPassiveData.List; break; default: break; } DataCount = BounceList.Count; BounceType = BounceType.Substring(0, 1) + BounceType.Substring(1, BounceType.Length - 1); Action = (this.Action == "ready" ? "Aktif" : (this.Action == "done" ? "Pasif" : "Genel")); return BounceList; } }}An last one, Controller as follows;
[GridAction]public ActionResult _BindBounceList(DateTime? start = null, DateTime? end = null, String bType = null){ string action = (String.IsNullOrEmpty(Request.QueryString["action"]) ? string.Empty : Request.QueryString["action"]); ReportManager.ActiveBulletin = new Guid(Session[SessionParameters.ACTIVE_BULLETIN].ToString()); BounceDetailList result = (BounceDetailList)ReportManager.BounceDetailList(action, bType, start, end); return View(new GridModel { Data = result.BounceList });}Any help would be greatly appreciated.
Thank you.