This is a migrated thread and some comments may be shown as answers.

Can someone help me please???

1 Answer 25 Views
Grid
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
bogus
Top achievements
Rank 1
bogus asked on 29 Oct 2010, 03:18 PM
This is my view:

<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage" %>

<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
    Index
</asp:Content>

<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
    <h2>Items</h2>
     <%= Html.Telerik().Grid<Template.Data.Item>()
        .Name("ItemsGrid")
        .DataBinding(binding => binding.Ajax().Select("GetGridSource", "Articole"))
        .Columns(columns=>
            {
                columns.Bound(l => l.Id);
                columns.Bound(l => l.Name);
            })
        .Selectable()
        .Scrollable(x=>x.Enabled(true))
        .EnableCustomBinding(true)
        .Pageable(paging => paging.Total((int)ViewData["ItemsCount"]))
    %>

</asp:Content>

This is the controller , that works fine
 public class ArticoleController : Controller
    {
        public ActionResult Index()
        {
            ViewData["ItemsCount"] = 1;
            return View();
        }

        [GridAction(EnableCustomBinding = true)]
        public ActionResult GetGridSource(GridCommand command)
        {
            IEnumerable<Item> data = new List<Item>
            {
                new Item{ Id=1,Name="name"}
            };
            return View(new GridModel(data)
            {
                Total = 1
            });
        }
    }

This is the controller that doesn't work:
public class ArticoleController : Controller
    {
        public ActionResult Index()
        {
            ViewData["ItemsCount"] = 1;
            return View();
        }

        [GridAction(EnableCustomBinding = true)]
        public ActionResult GetGridSource(GridCommand command)
        {
            IEnumerable<Item> data = new List<Item>
            {
                new Item{ Id=1,Name="name", Location=new Location{Name="location name"}}
            };
            return View(new GridModel(data)
            {
                Total = 1
            });
        }
    }
In this case i get "The requested URL returned 500".

1 Answer, 1 is accepted

Sort by
0
Bob
Top achievements
Rank 1
answered on 09 Nov 2010, 11:16 PM
I would try Location = {Name = "Location Name"} instead of Location = new Location{Name="Location Name"}.

Bob
Tags
Grid
Asked by
bogus
Top achievements
Rank 1
Answers by
Bob
Top achievements
Rank 1
Share this question
or