Advertisement

05.14.2008 at 12:54AM PDT, ID: 23400516 | Points: 500
[x]
Attachment Details

Making an asp:BoundField Display a Column From a Table relation

Asked by peter_thomas in Programming for ASP.NET, .NET, .NET Framework 2.0

Tags: ASP.NET, XML & VB.NET, IE 6-7

Hi,
I have got a GridView which is linked to a table (tbl1), I want to display records from tbl1 and records from a table that is linked through a relation to tbl1 (tbl2) where the tables are linked through a primary key.

The way the software is designed i cannot use straight SQL do achieve this so i must use the relation to make this work.
The code attached is what i have done so far.

Code examples would be very appreciated
ThanxStart Free Trial
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
The gridview:
<asp:GridView ID="GlobalContractHeaderGrid1" runat="server" AutoGenerateColumns="False"
                DataKeyNames="CompanyID,DivisionID,DepartmentID,CustomerID" DataMember="GlobalContractHeader"
DataSourceID="DBDataSource1" OnRowCommand="DBDataSource1.HandleGridCommand" >
 
<columns>
     <asp:BoundField DataField="CustomerId" HeaderText="<%$ Translation: Customer ID %>" SortExpression="CustomerId" />
 
     <asp:BoundField DataField="CustomerPhone" HeaderText="<%$ Translation: Customer Phone %>" SortExpression="CustomerPhone" />
</columns>
</asp:GridView>
--------------------------------------------------------
The table:
<?xml version="1.0" encoding="utf-8" ?>
<table name="GlobalContractHeader" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"  order-by="CustomerID DESC" >
  
<columns>
    <column name="CompanyID" type="xs:string" maxlength="36" nullable="false" key="true" session="true" />
    <column name="DivisionID" type="xs:string" maxlength="36" nullable="false" key="true" session="true" />
    <column name="DepartmentID" type="xs:string" maxlength="36" nullable="false" key="true" session="true" />
<column name="CustomerID" type="xs:string" maxlength="50" />
</columns>
  <relations>
 <relation name="CustomerInformation_Via_CustomerID" type="lookup" table="CustomerInformation" load-at-once="true">
      <viewfilters>
        <column name="CompanyID" target="CompanyID"/>
        <column name="DivisionID" target="DivisionID"/>
        <column name="DepartmentID" target="DepartmentID"/>
        <column name="CustomerID" target="CustomerID"/>
      </viewfilters>
      <columns>
        <column name="CompanyID" target="CompanyID"/>
        <column name="DivisionID" target="DivisionID"/>
        <column name="DepartmentID" target="DepartmentID"/>
        <column name="CustomerPhone" target="CustomerPhone"/>
      </columns>
    </relation>
  </relations>
</table>
[+][-]05.15.2008 at 12:24AM PDT, ID: 21571260

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]05.15.2008 at 12:59AM PDT, ID: 21571399

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
 
Loading Advertisement...
20080716-EE-VQP-32 / EE_QW_2_20070628