Click here to Skip to main content
12,399,561 members (51,365 online)
Rate this:
Please Sign up or sign in to vote.
See more: ASP.NET
Is there a way to add the value from a navigation key on a DataGrid column that is bound to a field from it's Entity container field. This sounds hard to describe!

I have a field that holds a weight, same table has a referenced table for types of weight i.e. lbs, kgs, etc... So I want the column to show 6kg instead of 6.

My first idea:

<asp:BoundColumn DataField="Weight" DataFormatString="{0:<%# Eval("WeightType.WeightType") %>}" HeaderText="Weight ></asp:BoundColumn>

I know illegal as all get out, so is there a way to concatenate this?
Posted 4-Jan-13 15:07pm
Updated 5-Jan-13 14:05pm

1 solution

Rate this: bad
Please Sign up or sign in to vote.

Solution 1

Just messing around I found you can use the ItemTemplate and add 2 labels, viola! Hope this helps someone else.

                  <asp:label id="lbHeader" runat="server" text="Weight" />
                  <asp:label id="lbWeight" runat="server" text="<%# Bind("Weight") %>" />
                  <asp:label id="lbWeightType" runat="server" text="<%# Bind("Weight.WeightType") %>" />

All I need now is a better title for searches.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web02 | 2.8.160721.1 | Last Updated 5 Jan 2013
Copyright © CodeProject, 1999-2016
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100