What you have is a "has-a" relationship or a one-to-one navigation b.com/tag/property">property in A to B that you want to access in your DevExpress Grid. You can do this by b.com/tag/set">setting your FieldName b.com/tag/property">property to your NavigationProperty.FieldName
Say for a one-to-one relationship of Persont to Address like the following:
public class Person
{
public int ID { get; b.com/tag/set">set; }
public string FirstName { get; b.com/tag/set">set; }
public string LastName { get; b.com/tag/set">set; }
public virtual Address Address { get; b.com/tag/set">set; }
}
public class Address
{
public int ID { get; b.com/tag/set">set; }
public string StreetAddress { get; b.com/tag/set">set; }
public string City { get; b.com/tag/set">set; }
public string State { get; b.com/tag/set">set; }
public string Zip { get; b.com/tag/set">set; }
}
Your GridView in your aspx b.com/tag/page">page to include both the Person and the StreeAddress b.com/tag/property">property of the Address navigation b.com/tag/property">property would look like this
<dx:ASPxGridView ID="ASPxGridView1" runat="server">
<Columns>
<dx:GridViewDataTextColumn FieldName="FirstName" VisibleIndex="0">
dx:GridViewDataTextColumn>
<dx:GridViewDataTextColumn FieldName="LastName" VisibleIndex="1">
dx:GridViewDataTextColumn>
<dx:GridViewDataTextColumn FieldName="Address.StreetAddress" VisibleIndex="1">
dx:GridViewDataTextColumn>
Columns>
dx:ASPxGridView>
In this case, Person being table A and Address being table B. You are binding your gridview on A so then you would be b.com/tag/set">setting your field name to B.FieldToDisplay.
Hope this helps!
manpreet
Best Answer
2 years ago
I've got two tables in SQL Server, say A and B. B is a list of documents, and A contains data indicating whether a project should include a row in B.
I have POCOs for A and B, but ultimately what I'm after is something I can bind to a devExpress grid that contains the data from both (BDocNumber, BName, Include)
I can set up B as a navigation property, but I don't know a way to flatten that out for the grid (DevExpress ASPxGridView, server mode)
I've also looked into entity splitting, but it appears that won't work since I want to join on BId instead of AId.
A solution to either 1 or 2 is acceptable, but learning about both would be awesome.
Thanks