Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

Troubleshooting
Research
Professional Opinions
Ask a Question
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE

troubleshooting Question

GridView binding to foreign column name rather than id

Avatar of Programmer_to_be
Programmer_to_be asked on
C#ASP.NET
6 Comments1 Solution641 ViewsLast Modified:
Hi,

I am binding a GridView to a typed DataTable, I have AutoGenerateColumns set to False. The table I'm binding the GridView to looks like this:

Title | Price | PlatformID

PlatformID is a foreign key into another database table (Platform) which has a column "Name". In the GridView, I don't want PlatformID, but I want to resolve the Name from this ID.

How can I do this? I'm binding the normal columns as:

<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="false" AllowSorting="true">
        <Columns>
            <asp:BoundField DataField="Title" HeaderText="Title" />
            <asp:BoundField DataField="Price" HeaderText="Price" DataFormatString="{0:c}" />
        </Columns>
    </asp:GridView>

That works fine, but when I try add another BoundField like:

<asp:BoundField DataField="PlatformRow.Name" HeaderText="Platform" />

I get the runtime error:
"A field or property with the name 'PlatformRow.Name' was not found on the selected data source.

Anyway to do this?
ASKER CERTIFIED SOLUTION
Avatar of Tom Beck
Commented:
This problem has been solved!
Unlock 1 Answer and 6 Comments.
See Answers