Click here to Skip to main content
Rate this: bad
Please Sign up or sign in to vote.
See more: ASP.NETEntities
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
Edited 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
Your Filters
0 Shai Vashdi 576
1 OriginalGriff 183
2 Tadit Dash 150
3 Peter Leow 140
4 Sergey Alexandrovich Kryukov 121
0 Sergey Alexandrovich Kryukov 9,280
1 OriginalGriff 5,473
2 Peter Leow 4,100
3 Maciej Los 3,540
4 Abhinav S 3,333

Advertise | Privacy | Mobile
Web01 | 2.8.140415.2 | Last Updated 5 Jan 2013
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Use
Layout: fixed | fluid