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:

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
6 Comments1 Solution641 ViewsLast Modified:

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">
            <asp:BoundField DataField="Title" HeaderText="Title" />
            <asp:BoundField DataField="Price" HeaderText="Price" DataFormatString="{0:c}" />

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?
Avatar of Tom Beck
This problem has been solved!
Unlock 1 Answer and 6 Comments.
See Answers