I have a scenario similar to the following
There is Product Table with its details
And there is another Supplier Table with supplier details
Product Table has productID as the primary key and SupplierID
The SupplierID is the PK fir Supplier table
But in the DB side SupplierID is not tagged as the FK on the Product table
But we know how it works.. ANd i am not permitted to change anything on the DB
Ok so in the ASP.Net project i drag both these table in to the ORM file .dbml
And add associtation between the Supplier(Parent) and Product (Child)
And i want to diaply the info in a GridView
In the Gridview instead of Supplier ID i want to have SupplierName (which is a prop in Supplier Table) along with the product tables..
So this is what i do
<asp:GridView ID="GridView1" runat="server" AllowPaging="True" AllowSorting="True"
AutoGenerateColumns="False" DataKeyNames="ProductID" DataSourceID="LDS_Product">
<asp:CommandField ShowDeleteButton="True" ShowEditButton="True" />
<asp:BoundField DataField="ProductID" HeaderText="ProductID" InsertVisible="False" ReadOnly="True"
<asp:BoundField DataField="ProductName" HeaderText="ProductName" InsertVisible="False" ReadOnly="True" SortExpression="ProductName" />
<asp:TemplateField HeaderText="Supplier " SortExpression="Supplier.SupplierID">
<asp:LinqDataSource ID="LDS_Product" runat="server" ContextTypeName="DataClassesDataContext"
EnableDelete="True" EnableInsert="True" EnableUpdate="True" TableName="Products"
Where="ProductName == @PName">
<asp:ControlParameter ControlID="TB_Product" Name="ProductName " PropertyName="Text" Type="String" />
I am sure there is something missing .. cos how can i mention Supplier.SupplierName where supplier is not a property on Product Data class..
And i get this error
Server Error in '/CustomerService' Application.
DataBinding: 'Product' does not contain a property with the name 'Supplier.
What is going wrong here
Can i add property Supplier declaratively without changing code..? or do a join in the LinqdataSource what is used by the GridView...
I am pretty new to these areas..
Any detailed help is appreciated