For example, in my WCF, if I have a Customer table and an Order table that have an association to each other on Customer ID.
I want to get the Count of the number of Orders for each Customer.
In regular VB code I can just do this:
Dim CustID As Integer = 1234 Dim cust As New MyService.Customer() cust = cust.GetCustomer(CustID) Response.Write(cust.Orders.Count)
The above code works fine but if I want to access the same from within a GridView, it doesn’t seem to react the same way (albiet, from a different method but I’m applying the same pricipals to each method though)
<asp:ObjectDataSource ID='odsCustomers' runat='server' SelectMethod='GetCustomers' TypeName='MyService.Customer' /> <asp:GridView ...> ... <Columns> <asp:BoundField DataField='Orders.Count' HeaderText='Order Count' /> </Columns> ... </asp:GridView>
So how could I do something like this?
You could try adding a partial method to the Customer class called OrderCount and reference that in your BoundField. Right click you dbml file and go to View Code then add.
VB
C#