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

[Solved] MVC Grid Binding issue

1 Answer 95 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Charley
Top achievements
Rank 1
Charley asked on 24 Jun 2011, 06:50 PM
I am certain I am missing something but here goes.  I create separate projects for the Model, BLL, and DAL.  I created a controller with code

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using IMRS.Model;
using IMRS.BLL;
using Telerik.Web.Mvc;
using Telerik.Web.Mvc.UI;
 
namespace IMRS.Controllers
{
    [HandleError]
    public class JobCodesController : Controller
    {
 
        //
        // GET: /JobCodes/
        [GridAction]
        public ActionResult Index()
        {
            JobCodesBLL jobCodesBLL = new JobCodesBLL();
            //JobCode jobCode = jobCodesBLL.GetJobCodeById(1);
 
            ViewData["jobCode"] = jobCodesBLL.GetJobCodeById(1);
            return View();
        }
}

I then created a view off the Index with code

@using IMRS.Model
@using Telerik.Web.Mvc.UI
 
@{
    ViewBag.Title = "View All Job Codes";
}
 
<h2>Index</h2>
@(
    Html.Telerik().Grid<IMRS.Model.JobCode>("jobCode").Name("AllJobCodes")
        .DataKeys(k => k.Add(o => o.ID))
        .Columns(c =>
        {
            c.Bound(o => o.JobCodeNumber).ReadOnly();
            c.Bound(o => o.Description).ReadOnly();
        })
        .DataBinding(b => b.Server())
)

The problem I am having is that in the controller the ViewData does get populated correctly it is confirmed the object is being filled and passed to the viewdata object under my chosen key.  Once you visit the page which contains the grid control states there is no data.  The two columns show the correct names as expected but it states there is no data.  Please help.

Thanks for the reply.

1 Answer, 1 is accepted

Sort by
0
Atanas Korchev
Telerik team
answered on 27 Jun 2011, 07:12 AM
Hello Charley,

 You should name your grid "jobCode":

Html.Telerik().Grid<IMRS.Model.JobCode>().Name("jobCode")

Regards,
Atanas Korchev
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Tags
General Discussions
Asked by
Charley
Top achievements
Rank 1
Answers by
Atanas Korchev
Telerik team
Share this question
or