I have two tables:
Entity
ID (PK, int)
NameUsers
Entity_ID (FK to the Entity.ID)
FName
LName
Now I want to show all columns from both tables to my GridView using QueryString. I got the QueryString part through configuration of LDS. I cannot see how you can link both tables in one LDS?
Here is the markup of my code:
<asp:GridView ID="GridView1" runat="server" AllowPaging="True"
AllowSorting="True" AutoGenerateColumns="False"
DataSourceID="LinqDataSource1" Height="209px" Width="648px">
<Columns>
<asp:BoundField DataField="Name" HeaderText="Name" ReadOnly="True"
SortExpression="Name" />
<asp:BoundField DataField="Description" HeaderText="Description"
ReadOnly="True" SortExpression="Description" />
<asp:BoundField DataField="Company" HeaderText="Company" ReadOnly="True"
SortExpression="Company" />
<asp:BoundField DataField="Phone" HeaderText="Phone" ReadOnly="True"
SortExpression="Phone" />
<asp:BoundField DataField="Fax" HeaderText="Fax" ReadOnly="True"
SortExpression="Fax" />
<asp:BoundField DataField="Email" HeaderText="Email" ReadOnly="True"
SortExpression="Email" />
<asp:BoundField DataField="ID" HeaderText="ID" ReadOnly="True"
SortExpression="ID" />
<asp:BoundField DataField = 'Bind("Users.FirstName")' />
</Columns>
</asp:GridView>
<asp:LinqDataSource ID="LinqDataSource1" runat="server"
ContextTypeName="EntityRegistration.DataAccess.OISLinq2SqlVs1DataContext"
EnableInsert="True" EnableUpdate="True" EntityTypeName="" OrderBy="ID"
Select="new (Name, Description, Company, Phone, Fax, Email, ID)"
TableName="Entities" Where="ID == @ID">
<WhereParameters>
<asp:QueryStringParameter Name="ID" QueryStringField="EntityID" Type="Int32" />
</WhereParameters>
</asp:LinqDataSource>
As you can see I have also added this column:
asp:BoundField DataField = 'Bind("Users.FirstName")'
Dont know what I am doing wrong here? Any comments?