Display Navigation Property on RadGrid Column RRS feed

  • Question

  • Hello!

    I'm having a problem with my RadGrid...Can you shouw me how can i on my asp.cs file(code behind) set the column value of my grid with a navigation property field?

    RadGrid1.DataSource = this.SapDocuments; 

    I'm using Entity, and I have the a table SapDocuments with a foreign Key of the field Process to another Table "Staging",

    At this moment my grid comes with its value at null...

    I need to set those two column values with the value of my navigation property....I can access to it like that:



    <MasterTableView GridLines="None" Width="100%" ViewStateMode="Disabled" CommandItemSettings-ShowExportToCsvButton="True"
        CommandItemSettings-ShowAddNewRecordButton="false" CommandItemDisplay="Top">
         <telerik:GridBoundColumn DataField="SequencialNumber" HeaderText="SequencialNumber"
          UniqueName="SequencialNumber" SortExpression="SequencialNumber">
         <telerik:GridBoundColumn DataField="SapDocuments.Priorities.Priority" HeaderText="Priority" UniqueName="Priority"
          FilterControlAltText="Filter Priority column" SortExpression="Priority" DataType="System.Int32">
         <telerik:GridBoundColumn DataField="Process" HeaderText="Staging" UniqueName="Process"
          SortExpression="Process" FilterControlAltText="Filter Process column">

     this is my statement:

    public List<SapDocuments> GetSapDocumentsByUser(string userName) {   using (EscalonamentoFacturasEntities spDocs = new EscalonamentoFacturasEntities())   {     //Não é permitido projecções select new...     var documentsQuery = from sd in spDocs.SapDocuments               join ua in spDocs.UsersAssign               on new { sd.Staging.Process, sd.Priorities.Priority }               equals               new { ua.Process, ua.Priority }               where ua.UserName == userName                //ALterar User                select sd;      return documentsQuery.ToList(); 

    I'm getting an exception "The ObjectContext instance has been disposed and can no longer be used for operations that require a connection." on the DataModel.designer on line:

    get { return ((IEntityWithRelationships)this).RelationshipManager.GetRelatedReference<Priorit‌​ies>("EscalonamentoFacturasModel.FK_SapDocuments_Priorities", "Priorities").Value; } set

    • Moved by Larcolais Gong Thursday, August 11, 2011 9:20 AM (From:ADO.NET Entity Framework and LINQ to Entities)
    Tuesday, August 9, 2011 10:24 AM