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

ForeignKey Column

0 Answers 33 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.
Kiang
Top achievements
Rank 1
Kiang asked on 27 Apr 2012, 07:23 AM
[URGENT]
Controller
 
 
public ActionResult Index()
     {
         int id = 1 ;
         var columns = new[]
               {
                   new GridCommandColumnSettings
                   {
                       Commands =
                       {
                           new GridSelectActionCommand() ,
                           new GridDeleteActionCommand() ,
                           new GridEditActionCommand()
                       } ,
                       Width = "200px" ,
                       Title = "Commands"
                   }
               };
         ViewData["columns"] = columns;
         var recs = from o in ent.mprojects
                    where o.RecordStatus == "A"
                    select o;
         Session["CompanyName"] = new PMIS_DBEntities().mcompanies.Where(o => o.ID == id).Select(o => o.CompanyName).SingleOrDefault();
           
       return View(recs);
     }
 
 
 
 
VIEW
 
@model IEnumerable<PMIS.Models.mproject>
 
@(Html.Telerik().Grid<PMIS.Models.mproject>()
        .Name("Grid")
        .DataKeys(keys => keys.Add(c => c.ID))
        .DataBinding(dataBinding => dataBinding.Server()
            .Update("Edit", "mproject_")
            .Delete("Delete", "mproject_"))
            .Columns(columns =>
            {
                columns.Bound(o => o.ProjectCode).Width(100);
                columns.Bound(o => o.Description).Width(100);
                columns.Bound(o => o.CompanyId).Width(100);
                columns.ForeignKey(o => o.CompanyId, (System.Collections.IEnumerable)Session["mcompany"], "ID" ,"CompanyName");
                columns.Bound(o => o.LastUpdateDate).Width(100);
                columns.Bound(o => o.LastUpdateUserId).Width(100);
                columns.Command(cmd => cmd.Custom("Edit").Text("Edit").DataRouteValues(key => key.Add(o => o.ID).RouteKey("mprojectID")).Action("Edit", "mproject_"));
                columns.Command(cmd => cmd.Delete().ButtonType(GridButtonType.Text));
            })
        .Pageable()
        .Sortable()
)


I've got some data inside database but there is no data when i view the page..  
Tags
General Discussions
Asked by
Kiang
Top achievements
Rank 1
Share this question
or