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

ADO.NET Data Service Binding with $Expand

2 Answers 57 Views
Grid
This is a migrated thread and some comments may be shown as answers.
George
Top achievements
Rank 1
George asked on 08 Dec 2008, 10:54 PM
Hey there folks,

I have an issue, and I'm not sure if I'm just not getting it because documentation and examples are still pretty thin, or if it is just not possible.  I'll try to keep it as simple as I can (ya right!).

I'm using ADO.NET Data Services in a project, and I want to bind a Method called from this service to a RadGrid.  However, the resulting ATOM data contains the primary table, along with all of it's $EXPANDed tables.

When I bind to the RadGrid, I see the primary table, but I have no idea how to get to the data in the other tables.  Can the RadGrid even bind to that data?  If so, can someone provide an example?  Here is some more detail on what I am doing:

The Data Service Method:

[WebGet]   
public IQueryable<Customer> GetCustomerByID(int CustID)   
{   
    IQueryable<Customer> query =   
        from c in this.CurrentDataSource.Customer   
        where c.CustomerID == CustID   
        orderby c.CompanyName   
        select c;   
 
    return (query);  
}  
 


Simple enough, it pulls one record from the Customer table based on the primary key.  (Yes, I know the default entities do the exact same thing, but this service is actually more complicated then what I am presenting here!).

The Business Layer:

        public IQueryable<Customer> GetCustomerByID(int CustID)  
        {  
            NeoDemoDBEntities ctx = new NeoDemoDBEntities(new Uri("http://localhost/NeoDemoService/NeoDemoSvc.svc", UriKind.Absolute));  
            var query =  
                ctx.CreateQuery<Customer>("/GetCustomerByID")  
                    .AddQueryOption("CustID", CustID)  
                    .Expand("CustomerAddress")  
                    .Expand("CustomerDetail")  
                    .Expand("CustomerCharge")  
                    .Expand("CustomerGroup");  
 
            return query;  
        } 
Also pretty simple.  The code here in the BL is the equivilent of:

http://localhost/NeoDemoService/NeoDemoSvc.svc/GetCustomerByID()?$expand=CustomerAddress,CustomerDetail,CustomerCharge,CustomerGroup&CustID=699

The UI:

I know this is incomplete, but here is what the page does to the control:

        protected void Page_Load(object sender, EventArgs e)  
        {  
 
            NeoDemoBL.NeoDemoBL BL = new NeoDemoBL.NeoDemoBL();  
            RadGrid1.MasterTableView.DataSource = BL.GetCustomerByID(699);  
            RadGrid1.DataBind();  
        }  
 
The reason it is incomplete is I don't know where to go from here.


Here is the resulting XML.  The data looks strange becuase I used a data generator.  So, if anyone could smack me in the head and tell me what I'm missing, or tell me I can't do, or just tell me something!  I'd appreciate it! 

Thanks, Kuba

<?xml version="1.0" encoding="utf-8" standalone="yes"?>  
<feed xml:base="http://localhost/NeoDemoService/NeoDemoSvc.svc/" xmlns:d="http://schemas.microsoft.com/ado/2007/08/dataservices" xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata" xmlns="http://www.w3.org/2005/Atom">  
  <title type="text">GetCustomerByID</title> 
  <id>http://localhost/NeoDemoService/NeoDemoSvc.svc/GetCustomerByID</id> 
  <updated>2008-12-08T22:43:38Z</updated> 
  <link rel="self" title="GetCustomerByID" href="GetCustomerByID" /> 
  <entry> 
    <id>http://localhost/NeoDemoService/NeoDemoSvc.svc/Customer(699)</id> 
    <title type="text"></title> 
    <updated>2008-12-08T22:43:38Z</updated> 
    <author> 
      <name /> 
    </author> 
    <link rel="edit" title="Customer" href="Customer(699)" /> 
    <link rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/CustomerGroup" type="application/atom+xml;type=entry" title="CustomerGroup" href="Customer(699)/CustomerGroup">  
      <m:inline> 
        <entry> 
          <id>http://localhost/NeoDemoService/NeoDemoSvc.svc/CustomerGroup(943)</id> 
          <title type="text"></title> 
          <updated>2008-12-08T22:43:38Z</updated> 
          <author> 
            <name /> 
          </author> 
          <link rel="edit" title="CustomerGroup" href="CustomerGroup(943)" /> 
          <link rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/Customer" type="application/atom+xml;type=feed" title="Customer" href="CustomerGroup(943)/Customer" /> 
          <category term="NeoDemoDBModel.CustomerGroup" scheme="http://schemas.microsoft.com/ado/2007/08/dataservices/scheme" /> 
          <content type="application/xml">  
            <m:properties> 
              <d:CustomerGroupID m:type="Edm.Int32">943</d:CustomerGroupID> 
              <d:GroupName>Henry Yoder</d:GroupName> 
              <d:Description>Pro linguens imaginator pars fecit.  Et quad ut no</d:Description> 
              <d:isSubGroup m:type="Edm.Boolean">false</d:isSubGroup> 
              <d:ParentGroupID m:type="Edm.Int32">943</d:ParentGroupID> 
              <d:CreatedByUser m:type="Edm.Int32">1172248618</d:CreatedByUser> 
              <d:CreatedDateTime m:type="Edm.DateTime">1993-06-22T23:21:08.47</d:CreatedDateTime> 
              <d:ModifiedByUser m:type="Edm.Int32">-1067266761</d:ModifiedByUser> 
              <d:ModifiedDateTime m:type="Edm.DateTime">1963-11-18T00:48:58.37</d:ModifiedDateTime> 
              <d:timestamp m:type="Edm.Binary">AAAAAAFYyCY=</d:timestamp> 
            </m:properties> 
          </content> 
        </entry> 
      </m:inline> 
    </link> 
    <link rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/CustomerAddress" type="application/atom+xml;type=feed" title="CustomerAddress" href="Customer(699)/CustomerAddress">  
      <m:inline> 
        <feed> 
          <title type="text">CustomerAddress</title> 
          <id>http://localhost/NeoDemoService/NeoDemoSvc.svc/Customer(699)/CustomerAddress</id> 
          <updated>2008-12-08T22:43:38Z</updated> 
          <link rel="self" title="CustomerAddress" href="Customer(699)/CustomerAddress" /> 
          <entry> 
            <id>http://localhost/NeoDemoService/NeoDemoSvc.svc/CustomerAddress(12)</id> 
            <title type="text"></title> 
            <updated>2008-12-08T22:43:38Z</updated> 
            <author> 
              <name /> 
            </author> 
            <link rel="edit" title="CustomerAddress" href="CustomerAddress(12)" /> 
            <link rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/Customer" type="application/atom+xml;type=entry" title="Customer" href="CustomerAddress(12)/Customer" /> 
            <category term="NeoDemoDBModel.CustomerAddress" scheme="http://schemas.microsoft.com/ado/2007/08/dataservices/scheme" /> 
            <content type="application/xml">  
              <m:properties> 
                <d:CustomerAddressID m:type="Edm.Int32">12</d:CustomerAddressID> 
                <d:AddressType>51 White First Freeway</d:AddressType> 
                <d:Contact>UV31W0WKRAGPWXA</d:Contact> 
                <d:Address1>381 North Hague Blvd.</d:Address1> 
                <d:Address2>15 East Nobel Street</d:Address2> 
                <d:Address3>670 White Milton Avenue</d:Address3> 
                <d:Address4>89 New Road</d:Address4> 
                <d:City>Garland</d:City> 
                <d:State>Ohio</d:State> 
                <d:PostalCode>74358</d:PostalCode> 
                <d:Country>Eire</d:Country> 
                <d:Region>IL-WU</d:Region> 
                <d:Phone>758647-7586</d:Phone> 
                <d:Fax>9208703855</d:Fax> 
                <d:Email>iivvcrea1@dwpkip.com</d:Email> 
                <d:CreatedDateTime m:type="Edm.DateTime">1961-05-06T17:21:23.17</d:CreatedDateTime> 
                <d:CreatedByUser m:type="Edm.Int32">1107057168</d:CreatedByUser> 
                <d:ModifiedDateTime m:type="Edm.DateTime">1992-03-22T03:29:14.4</d:ModifiedDateTime> 
                <d:ModifiedByUser m:type="Edm.Int32">-1832928163</d:ModifiedByUser> 
                <d:timestamp m:type="Edm.Binary">AAAAAAIQmFE=</d:timestamp> 
              </m:properties> 
            </content> 
          </entry> 
          <entry> 
            <id>http://localhost/NeoDemoService/NeoDemoSvc.svc/CustomerAddress(40)</id> 
            <title type="text"></title> 
            <updated>2008-12-08T22:43:38Z</updated> 
            <author> 
              <name /> 
            </author> 
            <link rel="edit" title="CustomerAddress" href="CustomerAddress(40)" /> 
            <link rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/Customer" type="application/atom+xml;type=entry" title="Customer" href="CustomerAddress(40)/Customer" /> 
            <category term="NeoDemoDBModel.CustomerAddress" scheme="http://schemas.microsoft.com/ado/2007/08/dataservices/scheme" /> 
            <content type="application/xml">  
              <m:properties> 
                <d:CustomerAddressID m:type="Edm.Int32">40</d:CustomerAddressID> 
                <d:AddressType>17 North Clarendon Avenue</d:AddressType> 
                <d:Contact>S3UV97LO2209QX</d:Contact> 
                <d:Address1>691 White Hague Freeway</d:Address1> 
                <d:Address2>105 Hague Avenue</d:Address2> 
                <d:Address3>23 Milton Freeway</d:Address3> 
                <d:Address4>366 Rocky Milton St.</d:Address4> 
                <d:City>Baltimore</d:City> 
                <d:State>Ohio</d:State> 
                <d:PostalCode>78347</d:PostalCode> 
                <d:Country>South Africa</d:Country> 
                <d:Region>NH-ID</d:Region> 
                <d:Phone>816998-4583</d:Phone> 
                <d:Fax>588-143-1008</d:Fax> 
                <d:Email>jdzhwqu.tsygfzw@vrmgps.com</d:Email> 
                <d:CreatedDateTime m:type="Edm.DateTime">1989-05-26T00:10:11.05</d:CreatedDateTime> 
                <d:CreatedByUser m:type="Edm.Int32">1709308041</d:CreatedByUser> 
                <d:ModifiedDateTime m:type="Edm.DateTime">1996-11-08T22:16:15.04</d:ModifiedDateTime> 
                <d:ModifiedByUser m:type="Edm.Int32">945275887</d:ModifiedByUser> 
                <d:timestamp m:type="Edm.Binary">AAAAAAIQmFI=</d:timestamp> 
              </m:properties> 
            </content> 
          </entry> 
          <entry> 
            <id>http://localhost/NeoDemoService/NeoDemoSvc.svc/CustomerAddress(61)</id> 
            <title type="text"></title> 
            <updated>2008-12-08T22:43:38Z</updated> 
            <author> 
              <name /> 
            </author> 
            <link rel="edit" title="CustomerAddress" href="CustomerAddress(61)" /> 
            <link rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/Customer" type="application/atom+xml;type=entry" title="Customer" href="CustomerAddress(61)/Customer" /> 
            <category term="NeoDemoDBModel.CustomerAddress" scheme="http://schemas.microsoft.com/ado/2007/08/dataservices/scheme" /> 
            <content type="application/xml">  
              <m:properties> 
                <d:CustomerAddressID m:type="Edm.Int32">61</d:CustomerAddressID> 
                <d:AddressType>91 First Blvd.</d:AddressType> 
                <d:Contact>E1E05BFGK4SEXMQ8GOWOL</d:Contact> 
                <d:Address1>83 West Cowley Road</d:Address1> 
                <d:Address2>97 White Fabien St.</d:Address2> 
                <d:Address3>316 Green Oak Road</d:Address3> 
                <d:Address4>586 Fabien Road</d:Address4> 
                <d:City>Omaha</d:City> 
                <d:State>Missouri</d:State> 
                <d:PostalCode>00961</d:PostalCode> 
                <d:Country>Madagascar</d:Country> 
                <d:Region>WI-SF</d:Region> 
                <d:Phone>266-5445765</d:Phone> 
                <d:Fax>5054591383</d:Fax> 
                <d:Email>mqpw.hqcnccifs@dilvbgdv.cbxict.org</d:Email> 
                <d:CreatedDateTime m:type="Edm.DateTime">1985-10-08T11:25:57.6</d:CreatedDateTime> 
                <d:CreatedByUser m:type="Edm.Int32">220543920</d:CreatedByUser> 
                <d:ModifiedDateTime m:type="Edm.DateTime">1987-04-29T05:58:50.15</d:ModifiedDateTime> 
                <d:ModifiedByUser m:type="Edm.Int32">2096046239</d:ModifiedByUser> 
                <d:timestamp m:type="Edm.Binary">AAAAAAIQmFM=</d:timestamp> 
              </m:properties> 
            </content> 
          </entry> 
          <entry> 
            <id>http://localhost/NeoDemoService/NeoDemoSvc.svc/CustomerAddress(1399)</id> 
            <title type="text"></title> 
            <updated>2008-12-08T22:43:38Z</updated> 
            <author> 
              <name /> 
            </author> 
            <link rel="edit" title="CustomerAddress" href="CustomerAddress(1399)" /> 
            <link rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/Customer" type="application/atom+xml;type=entry" title="Customer" href="CustomerAddress(1399)/Customer" /> 
            <category term="NeoDemoDBModel.CustomerAddress" scheme="http://schemas.microsoft.com/ado/2007/08/dataservices/scheme" /> 
            <content type="application/xml">  
              <m:properties> 
                <d:CustomerAddressID m:type="Edm.Int32">1399</d:CustomerAddressID> 
                <d:AddressType>72 Green Hague Street</d:AddressType> 
                <d:Contact>S82UBER9L0NOMZX0046Z1E3QSJBASFKZIG9RSTAXH</d:Contact> 
                <d:Address1>626 Rocky Hague Boulevard</d:Address1> 
                <d:Address2>893 Cowley Blvd.</d:Address2> 
                <d:Address3>782 Clarendon Drive</d:Address3> 
                <d:Address4>83 Milton Street</d:Address4> 
                <d:City>Riverside</d:City> 
                <d:State>Pennsylvania</d:State> 
                <d:PostalCode>47846</d:PostalCode> 
                <d:Country>Taiwan</d:Country> 
                <d:Region>ID-EM</d:Region> 
                <d:Phone>882359-2934</d:Phone> 
                <d:Fax>080-7809038</d:Fax> 
                <d:Email>fhwsm.akyhh@urgf--.org</d:Email> 
                <d:CreatedDateTime m:type="Edm.DateTime">1962-12-14T10:52:24.29</d:CreatedDateTime> 
                <d:CreatedByUser m:type="Edm.Int32">-1869840069</d:CreatedByUser> 
                <d:ModifiedDateTime m:type="Edm.DateTime">1969-08-28T13:59:17.07</d:ModifiedDateTime> 
                <d:ModifiedByUser m:type="Edm.Int32">-1271843384</d:ModifiedByUser> 
                <d:timestamp m:type="Edm.Binary">AAAAAAFvxEo=</d:timestamp> 
              </m:properties> 
            </content> 
          </entry> 
        </feed> 
      </m:inline> 
    </link> 
    <link rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/CustomerCharge" type="application/atom+xml;type=feed" title="CustomerCharge" href="Customer(699)/CustomerCharge">  
      <m:inline> 
        <feed> 
          <title type="text">CustomerCharge</title> 
          <id>http://localhost/NeoDemoService/NeoDemoSvc.svc/Customer(699)/CustomerCharge</id> 
          <updated>2008-12-08T22:43:38Z</updated> 
          <link rel="self" title="CustomerCharge" href="Customer(699)/CustomerCharge" /> 
          <entry> 
            <id>http://localhost/NeoDemoService/NeoDemoSvc.svc/CustomerCharge(8)</id> 
            <title type="text"></title> 
            <updated>2008-12-08T22:43:38Z</updated> 
            <author> 
              <name /> 
            </author> 
            <link rel="edit" title="CustomerCharge" href="CustomerCharge(8)" /> 
            <link rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/Customer" type="application/atom+xml;type=entry" title="Customer" href="CustomerCharge(8)/Customer" /> 
            <category term="NeoDemoDBModel.CustomerCharge" scheme="http://schemas.microsoft.com/ado/2007/08/dataservices/scheme" /> 
            <content type="application/xml">  
              <m:properties> 
                <d:CustomerChargeID m:type="Edm.Int32">8</d:CustomerChargeID> 
                <d:LastInvoiceDate m:type="Edm.DateTime">1993-09-27T07:53:03.31</d:LastInvoiceDate> 
                <d:LongTermDays m:type="Edm.Decimal">242428591000000000</d:LongTermDays> 
                <d:ShortLongBreakDays m:type="Edm.Decimal">744112993000000000</d:ShortLongBreakDays> 
                <d:LongTermStartDays m:type="Edm.Decimal">245797396000000000</d:LongTermStartDays> 
                <d:CreatedByUser m:type="Edm.Int32">-1664979409</d:CreatedByUser> 
                <d:CreatedDateTime m:type="Edm.DateTime">1966-09-15T00:02:10.22</d:CreatedDateTime> 
                <d:ModifiedByUser m:type="Edm.Int32">376368382</d:ModifiedByUser> 
                <d:ModifiedDateTime m:type="Edm.DateTime">1966-11-21T16:05:48.99</d:ModifiedDateTime> 
                <d:timestamp m:type="Edm.Binary">AAAAAAIQmFU=</d:timestamp> 
              </m:properties> 
            </content> 
          </entry> 
          <entry> 
            <id>http://localhost/NeoDemoService/NeoDemoSvc.svc/CustomerCharge(30)</id> 
            <title type="text"></title> 
            <updated>2008-12-08T22:43:38Z</updated> 
            <author> 
              <name /> 
            </author> 
            <link rel="edit" title="CustomerCharge" href="CustomerCharge(30)" /> 
            <link rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/Customer" type="application/atom+xml;type=entry" title="Customer" href="CustomerCharge(30)/Customer" /> 
            <category term="NeoDemoDBModel.CustomerCharge" scheme="http://schemas.microsoft.com/ado/2007/08/dataservices/scheme" /> 
            <content type="application/xml">  
              <m:properties> 
                <d:CustomerChargeID m:type="Edm.Int32">30</d:CustomerChargeID> 
                <d:LastInvoiceDate m:type="Edm.DateTime">2005-11-27T23:21:43.52</d:LastInvoiceDate> 
                <d:LongTermDays m:type="Edm.Decimal">767373501000000000</d:LongTermDays> 
                <d:ShortLongBreakDays m:type="Edm.Decimal">572733091000000000</d:ShortLongBreakDays> 
                <d:LongTermStartDays m:type="Edm.Decimal">378092682000000000</d:LongTermStartDays> 
                <d:CreatedByUser m:type="Edm.Int32">787549904</d:CreatedByUser> 
                <d:CreatedDateTime m:type="Edm.DateTime">2007-05-20T06:20:02.1</d:CreatedDateTime> 
                <d:ModifiedByUser m:type="Edm.Int32">-1283348979</d:ModifiedByUser> 
                <d:ModifiedDateTime m:type="Edm.DateTime">1985-12-21T18:43:21.52</d:ModifiedDateTime> 
                <d:timestamp m:type="Edm.Binary">AAAAAAIQmFQ=</d:timestamp> 
              </m:properties> 
            </content> 
          </entry> 
          <entry> 
            <id>http://localhost/NeoDemoService/NeoDemoSvc.svc/CustomerCharge(64)</id> 
            <title type="text"></title> 
            <updated>2008-12-08T22:43:38Z</updated> 
            <author> 
              <name /> 
            </author> 
            <link rel="edit" title="CustomerCharge" href="CustomerCharge(64)" /> 
            <link rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/Customer" type="application/atom+xml;type=entry" title="Customer" href="CustomerCharge(64)/Customer" /> 
            <category term="NeoDemoDBModel.CustomerCharge" scheme="http://schemas.microsoft.com/ado/2007/08/dataservices/scheme" /> 
            <content type="application/xml">  
              <m:properties> 
                <d:CustomerChargeID m:type="Edm.Int32">64</d:CustomerChargeID> 
                <d:LastInvoiceDate m:type="Edm.DateTime">1978-10-01T19:17:46.97</d:LastInvoiceDate> 
                <d:LongTermDays m:type="Edm.Decimal">786560625000000000</d:LongTermDays> 
                <d:ShortLongBreakDays m:type="Edm.Decimal">104917734000000000</d:ShortLongBreakDays> 
                <d:LongTermStartDays m:type="Edm.Decimal">423274844000000000</d:LongTermStartDays> 
                <d:CreatedByUser m:type="Edm.Int32">1027149572</d:CreatedByUser> 
                <d:CreatedDateTime m:type="Edm.DateTime">1956-04-20T00:00:28.43</d:CreatedDateTime> 
                <d:ModifiedByUser m:type="Edm.Int32">1769314128</d:ModifiedByUser> 
                <d:ModifiedDateTime m:type="Edm.DateTime">1991-04-26T16:17:33.03</d:ModifiedDateTime> 
                <d:timestamp m:type="Edm.Binary">AAAAAAIQmFY=</d:timestamp> 
              </m:properties> 
            </content> 
          </entry> 
          <entry> 
            <id>http://localhost/NeoDemoService/NeoDemoSvc.svc/CustomerCharge(1399)</id> 
            <title type="text"></title> 
            <updated>2008-12-08T22:43:38Z</updated> 
            <author> 
              <name /> 
            </author> 
            <link rel="edit" title="CustomerCharge" href="CustomerCharge(1399)" /> 
            <link rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/Customer" type="application/atom+xml;type=entry" title="Customer" href="CustomerCharge(1399)/Customer" /> 
            <category term="NeoDemoDBModel.CustomerCharge" scheme="http://schemas.microsoft.com/ado/2007/08/dataservices/scheme" /> 
            <content type="application/xml">  
              <m:properties> 
                <d:CustomerChargeID m:type="Edm.Int32">1399</d:CustomerChargeID> 
                <d:LastInvoiceDate m:type="Edm.DateTime">1994-06-12T23:46:35.65</d:LastInvoiceDate> 
                <d:LongTermDays m:type="Edm.Decimal">814584337000000000</d:LongTermDays> 
                <d:ShortLongBreakDays m:type="Edm.Decimal">875547392000000000</d:ShortLongBreakDays> 
                <d:LongTermStartDays m:type="Edm.Decimal">936510447000000000</d:LongTermStartDays> 
                <d:CreatedByUser m:type="Edm.Int32">705971517</d:CreatedByUser> 
                <d:CreatedDateTime m:type="Edm.DateTime">1956-03-19T19:33:47.58</d:CreatedDateTime> 
                <d:ModifiedByUser m:type="Edm.Int32">107974832</d:ModifiedByUser> 
                <d:ModifiedDateTime m:type="Edm.DateTime">1962-12-02T22:40:40.36</d:ModifiedDateTime> 
                <d:timestamp m:type="Edm.Binary">AAAAAAFoG4E=</d:timestamp> 
              </m:properties> 
            </content> 
          </entry> 
        </feed> 
      </m:inline> 
    </link> 
    <link rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/CustomerDetail" type="application/atom+xml;type=feed" title="CustomerDetail" href="Customer(699)/CustomerDetail">  
      <m:inline> 
        <feed> 
          <title type="text">CustomerDetail</title> 
          <id>http://localhost/NeoDemoService/NeoDemoSvc.svc/Customer(699)/CustomerDetail</id> 
          <updated>2008-12-08T22:43:38Z</updated> 
          <link rel="self" title="CustomerDetail" href="Customer(699)/CustomerDetail" /> 
          <entry> 
            <id>http://localhost/NeoDemoService/NeoDemoSvc.svc/CustomerDetail(16)</id> 
            <title type="text"></title> 
            <updated>2008-12-08T22:43:38Z</updated> 
            <author> 
              <name /> 
            </author> 
            <link rel="edit" title="CustomerDetail" href="CustomerDetail(16)" /> 
            <link rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/Customer" type="application/atom+xml;type=entry" title="Customer" href="CustomerDetail(16)/Customer" /> 
            <category term="NeoDemoDBModel.CustomerDetail" scheme="http://schemas.microsoft.com/ado/2007/08/dataservices/scheme" /> 
            <content type="application/xml">  
              <m:properties> 
                <d:CustomerDetailID m:type="Edm.Int32">16</d:CustomerDetailID> 
                <d:CustomerType>Longam, e funem.  Quad rarendum habitatio quoque p</d:CustomerType> 
                <d:AccountTermsID m:type="Edm.Int32">16</d:AccountTermsID> 
                <d:AccountSalesAgentID m:type="Edm.Int32">32</d:AccountSalesAgentID> 
                <d:AccountPriceLevelID m:type="Edm.Int32">16</d:AccountPriceLevelID> 
                <d:ShipMethod>QCBJLFTXS90VMQ6710</d:ShipMethod> 
                <d:ShipVendor>I1Z960YCYAH5NBA2DJFRUBGMS0LJYPJ7V6</d:ShipVendor> 
                <d:ShipAccountNumber>SUV4523</d:ShipAccountNumber> 
                <d:CreditLimit m:type="Edm.Decimal">423591388000000000</d:CreditLimit> 
                <d:PaymentMethod></d:PaymentMethod> 
                <d:CardNumber>25725</d:CardNumber> 
                <d:NameOnCard>Teresa Melendez</d:NameOnCard> 
                <d:ExpirationDate m:type="Edm.DateTime">2003-09-09T16:26:40.3</d:ExpirationDate> 
                <d:AddressID m:type="Edm.Int32">16</d:AddressID> 
                <d:PostalCode>17242</d:PostalCode> 
                <d:CreatedDateTime m:type="Edm.DateTime">1996-09-25T22:32:02.7</d:CreatedDateTime> 
                <d:CreatedByUser m:type="Edm.Int32">1214105238</d:CreatedByUser> 
                <d:ModifiedDateTime m:type="Edm.DateTime">1955-06-09T10:35:37.63</d:ModifiedDateTime> 
                <d:ModifiedByUser m:type="Edm.Int32">652227917</d:ModifiedByUser> 
              </m:properties> 
            </content> 
          </entry> 
          <entry> 
            <id>http://localhost/NeoDemoService/NeoDemoSvc.svc/CustomerDetail(25)</id> 
            <title type="text"></title> 
            <updated>2008-12-08T22:43:38Z</updated> 
            <author> 
              <name /> 
            </author> 
            <link rel="edit" title="CustomerDetail" href="CustomerDetail(25)" /> 
            <link rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/Customer" type="application/atom+xml;type=entry" title="Customer" href="CustomerDetail(25)/Customer" /> 
            <category term="NeoDemoDBModel.CustomerDetail" scheme="http://schemas.microsoft.com/ado/2007/08/dataservices/scheme" /> 
            <content type="application/xml">  
              <m:properties> 
                <d:CustomerDetailID m:type="Edm.Int32">25</d:CustomerDetailID> 
                <d:CustomerType>Longam, e gravis delerium.  Versus esset in doloru</d:CustomerType> 
                <d:AccountTermsID m:type="Edm.Int32">25</d:AccountTermsID> 
                <d:AccountSalesAgentID m:type="Edm.Int32">40</d:AccountSalesAgentID> 
                <d:AccountPriceLevelID m:type="Edm.Int32">25</d:AccountPriceLevelID> 
                <d:ShipMethod>B7YR2NNXL9LUS</d:ShipMethod> 
                <d:ShipVendor>SIESET70S7VUN02FU59VSJ8S3LZA3S2YIGWCNRES2D7J</d:ShipVendor> 
                <d:ShipAccountNumber>YUB51289</d:ShipAccountNumber> 
                <d:CreditLimit m:type="Edm.Decimal">959660756000000000</d:CreditLimit> 
                <d:PaymentMethod>33MQI3L3BUINW87RT66ILIYAOKIM48</d:PaymentMethod> 
                <d:CardNumber>22518</d:CardNumber> 
                <d:NameOnCard>Kisha Lester</d:NameOnCard> 
                <d:ExpirationDate m:type="Edm.DateTime">1972-05-05T06:26:54.74</d:ExpirationDate> 
                <d:AddressID m:type="Edm.Int32">25</d:AddressID> 
                <d:PostalCode>60254</d:PostalCode> 
                <d:CreatedDateTime m:type="Edm.DateTime">1988-07-06T04:35:01.44</d:CreatedDateTime> 
                <d:CreatedByUser m:type="Edm.Int32">-1975701240</d:CreatedByUser> 
                <d:ModifiedDateTime m:type="Edm.DateTime">1999-04-17T11:20:25.9</d:ModifiedDateTime> 
                <d:ModifiedByUser m:type="Edm.Int32">-247808879</d:ModifiedByUser> 
              </m:properties> 
            </content> 
          </entry> 
          <entry> 
            <id>http://localhost/NeoDemoService/NeoDemoSvc.svc/CustomerDetail(35)</id> 
            <title type="text"></title> 
            <updated>2008-12-08T22:43:38Z</updated> 
            <author> 
              <name /> 
            </author> 
            <link rel="edit" title="CustomerDetail" href="CustomerDetail(35)" /> 
            <link rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/Customer" type="application/atom+xml;type=entry" title="Customer" href="CustomerDetail(35)/Customer" /> 
            <category term="NeoDemoDBModel.CustomerDetail" scheme="http://schemas.microsoft.com/ado/2007/08/dataservices/scheme" /> 
            <content type="application/xml">  
              <m:properties> 
                <d:CustomerDetailID m:type="Edm.Int32">35</d:CustomerDetailID> 
                <d:CustomerType>Versus esset in dolorum cognitio, travissimantor q</d:CustomerType> 
                <d:AccountTermsID m:type="Edm.Int32">35</d:AccountTermsID> 
                <d:AccountSalesAgentID m:type="Edm.Int32">29</d:AccountSalesAgentID> 
                <d:AccountPriceLevelID m:type="Edm.Int32">35</d:AccountPriceLevelID> 
                <d:ShipMethod>O3V5BMG3ZRMOR</d:ShipMethod> 
                <d:ShipVendor>PYPM9JC0D3PN2UZAVSCDYLYSJQUR7</d:ShipVendor> 
                <d:ShipAccountNumber>DEJ8</d:ShipAccountNumber> 
                <d:CreditLimit m:type="Edm.Decimal">993710639000000000</d:CreditLimit> 
                <d:PaymentMethod>R539F4TCJ1FY8PQGZ9SGR3TSCLJOQMKIVQES4FS7LJ590FSY</d:PaymentMethod> 
                <d:CardNumber>26378</d:CardNumber> 
                <d:NameOnCard>Timothy Pham</d:NameOnCard> 
                <d:ExpirationDate m:type="Edm.DateTime">1974-06-22T11:16:19.49</d:ExpirationDate> 
                <d:AddressID m:type="Edm.Int32">35</d:AddressID> 
                <d:PostalCode>84626</d:PostalCode> 
                <d:CreatedDateTime m:type="Edm.DateTime">1977-02-01T07:44:41.71</d:CreatedDateTime> 
                <d:CreatedByUser m:type="Edm.Int32">58385253</d:CreatedByUser> 
                <d:ModifiedDateTime m:type="Edm.DateTime">1960-07-01T05:23:36.52</d:ModifiedDateTime> 
                <d:ModifiedByUser m:type="Edm.Int32">793153851</d:ModifiedByUser> 
              </m:properties> 
            </content> 
          </entry> 
          <entry> 
            <id>http://localhost/NeoDemoService/NeoDemoSvc.svc/CustomerDetail(1399)</id> 
            <title type="text"></title> 
            <updated>2008-12-08T22:43:38Z</updated> 
            <author> 
              <name /> 
            </author> 
            <link rel="edit" title="CustomerDetail" href="CustomerDetail(1399)" /> 
            <link rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/Customer" type="application/atom+xml;type=entry" title="Customer" href="CustomerDetail(1399)/Customer" /> 
            <category term="NeoDemoDBModel.CustomerDetail" scheme="http://schemas.microsoft.com/ado/2007/08/dataservices/scheme" /> 
            <content type="application/xml">  
              <m:properties> 
                <d:CustomerDetailID m:type="Edm.Int32">1399</d:CustomerDetailID> 
                <d:CustomerType>Et quad estis vobis homo, si quad estis vobis homo</d:CustomerType> 
                <d:AccountTermsID m:type="Edm.Int32">1399</d:AccountTermsID> 
                <d:AccountSalesAgentID m:type="Edm.Int32">32</d:AccountSalesAgentID> 
                <d:AccountPriceLevelID m:type="Edm.Int32">1399</d:AccountPriceLevelID> 
                <d:ShipMethod>RD3HXJ6Q6KGGR1V76MH7BUB0DA6</d:ShipMethod> 
                <d:ShipVendor>JNWPI6K2BSYB9CUO2POSGWF4HAXEU0XTG5R8NTTTU</d:ShipVendor> 
                <d:ShipAccountNumber>SAZ3479</d:ShipAccountNumber> 
                <d:CreditLimit m:type="Edm.Decimal">606531138000000000</d:CreditLimit> 
                <d:PaymentMethod>JE54H0M</d:PaymentMethod> 
                <d:CardNumber>62597</d:CardNumber> 
                <d:NameOnCard>Kathy Downs</d:NameOnCard> 
                <d:ExpirationDate m:type="Edm.DateTime">1999-10-08T15:36:46.69</d:ExpirationDate> 
                <d:AddressID m:type="Edm.Int32">1399</d:AddressID> 
                <d:PostalCode>90962</d:PostalCode> 
                <d:CreatedDateTime m:type="Edm.DateTime">1954-10-31T08:17:05.84</d:CreatedDateTime> 
                <d:CreatedByUser m:type="Edm.Int32">1554074021</d:CreatedByUser> 
                <d:ModifiedDateTime m:type="Edm.DateTime">1961-07-15T11:23:58.62</d:ModifiedDateTime> 
                <d:ModifiedByUser m:type="Edm.Int32">956077336</d:ModifiedByUser> 
              </m:properties> 
            </content> 
          </entry> 
        </feed> 
      </m:inline> 
    </link> 
    <category term="NeoDemoDBModel.Customer" scheme="http://schemas.microsoft.com/ado/2007/08/dataservices/scheme" /> 
    <content type="application/xml">  
      <m:properties> 
        <d:CustomerID m:type="Edm.Int32">699</d:CustomerID> 
        <d:CustomerCode>R4950NA92</d:CustomerCode> 
        <d:CustomerName>Trent Colon</d:CustomerName> 
        <d:isActive m:type="Edm.Boolean">false</d:isActive> 
        <d:isArchive m:type="Edm.Boolean">true</d:isArchive> 
        <d:isSent m:type="Edm.Boolean">true</d:isSent> 
        <d:isOwner m:type="Edm.Boolean">false</d:isOwner> 
        <d:isVendor m:type="Edm.Boolean">false</d:isVendor> 
        <d:isCarrier m:type="Edm.Boolean">false</d:isCarrier> 
        <d:isSupplier m:type="Edm.Boolean">true</d:isSupplier> 
        <d:isCatchWeight m:type="Edm.Boolean">true</d:isCatchWeight> 
        <d:MailAddressID m:type="Edm.Int32">699</d:MailAddressID> 
        <d:ShipAddressID m:type="Edm.Int32">699</d:ShipAddressID> 
        <d:BillToAddressID m:type="Edm.Int32">699</d:BillToAddressID> 
        <d:CompanyName>Winglibexantor WorldWide Group</d:CompanyName> 
        <d:Website>JVE1SSPHXC4FJUZSXD47IU</d:Website> 
        <d:Comment>Longam, e funem.  Quad rarendum habitatio quoque p</d:Comment> 
        <d:Note>Id eudis quo plorum fecundio, et nomen transit. Pr</d:Note> 
        <d:CreatedDate m:type="Edm.DateTime">2001-06-22T18:47:03.99</d:CreatedDate> 
        <d:CreatedByUser m:type="Edm.Int32">-1734476941</d:CreatedByUser> 
        <d:ModifiedDate m:type="Edm.DateTime">1977-07-22T03:08:19.15</d:ModifiedDate> 
        <d:ModifiedByUser m:type="Edm.Int32">-1462488253</d:ModifiedByUser> 
        <d:timestamp m:type="Edm.Binary">AAAAAAFgb/k=</d:timestamp> 
      </m:properties> 
    </content> 
  </entry> 
</feed> 

2 Answers, 1 is accepted

Sort by
0
George
Top achievements
Rank 1
answered on 08 Dec 2008, 10:57 PM
One last thing.  I suppose I should have said that I am wanting a Hierarchal grid with a master and multiple children.  Just a small omission! :)

Thanks, Kuba
0
Rosen
Telerik team
answered on 11 Dec 2008, 05:21 PM
Hello Kuba Cole,

In order to achieve the desired functionality you should use AdvancedDataBinding and DetailTableDataBind. Inside the NeedDataSource you should cached the result into a field, then inside DetailTableDataBind event you should populate the DetailTable with the appropriate data. Note that you should set the HierarchyLoadMode to ServerBind. Similar to the following:

RadGrid's aspx declaration:
        <telerik:RadGrid runat="server" ID="RadGrid1" OnNeedDataSource="RadGrid1_NeedDataSource" 
            OnDetailTableDataBind="RadGrid1_DetailTableDataBind" AllowPaging="true">  
            <MasterTableView DataKeyNames="OrderID" HierarchyLoadMode="ServerBind">  
                <DetailTables> 
                    <telerik:GridTableView> 
                    </telerik:GridTableView> 
                </DetailTables> 
            </MasterTableView> 
        </telerik:RadGrid> 

cs
    private DataServiceQuery<Orders> _result;  
 
    protected void RadGrid1_NeedDataSource(object source, GridNeedDataSourceEventArgs e)  
    {  
        NorthwindEntities northwindEntities = new NorthwindEntities(new Uri("http://localhost:6058/WebSite52/WebDataService.svc"));  
 
        _result = northwindEntities.CreateQuery<Orders>("Orders");  
        ((RadGrid) source).DataSource = _result;  
    }  
 
    protected void RadGrid1_DetailTableDataBind(object source, GridDetailTableDataBindEventArgs e)  
    {  
        int orderId = (int)e.DetailTableView.ParentItem.GetDataKeyValue("OrderID");  
        e.DetailTableView.DataSource = _result.Where(n => n.OrderID == orderId).Select(n => n.Customers);  
    } 

Please give it a try and let us know about the result.

All the best,
Rosen
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Tags
Grid
Asked by
George
Top achievements
Rank 1
Answers by
George
Top achievements
Rank 1
Rosen
Telerik team
Share this question
or