Oct 1, 2009 at 5:34 AM

LookupField to Convert FK's into readable text .

Hi All,
I am desparately trying to get the LookupField object to work within GridView.At the moment in the display/readonly view all I get is Foreign Keys which dont mean much to anyone.

I have read the compiled help but don't see any usage information anywhere. It seems to be purely type information. How do I use it ?

I have two datasources, the first (MainGridSQL) returns a data set of PrimaryKey and a whole bunch of Foreign Keys. Thats it. Its purely an association table. So, I am trying to resolve the foreign keys to display them as labels when the GridView is in readonly mode. I am going crazy here trying to work it out. The second datasource (Plant) is the key and string based human readable info I am trying to display.

The drop down list works great (Edit mode) and resolves the FK to the Code for diplay just fine ('Code' is the column name). Update also works !

How do I get a loolup for a label in GridView read only mode ?

Can anyone help me with an example or point me in the right direction. Any help or advice greatly greatly appreciated !




                        <asp:GridView ID="GridView2" runat="server" AutoGenerateColumns="False"
                                DataKeyNames="TimeSheetId" DataSourceID="MainGridSQL"
                                AutoGenerateEditButton="True" AutoGenerateDeleteButton="True"
                            <asp:BoundField  DataField="TimeSheetId" HeaderText="TimeSheet" ReadOnly="True"
                                    SortExpression="TimeSheetId" InsertVisible="False" />
                            <asp:BoundField DataField="EmployeeId" HeaderText="Employee" SortExpression="EmployeeId" />
                            <asp:TemplateField HeaderText="Plant" >
                                    <asp:DropDownList ID="ddlPlantDropDown" SelectedValue='<%# Bind("PlantId") %>' DataSourceID="Plant"
                                    runat="server" DataTextField="Code" DataValueField ="PlantId" >
                                    <asp:Label ID="lblPlant" runat="server" Text='<%# Bind("PlantId") %>'></asp:Label>   

                        <asp:SqlDataSource ID="MainGridSQL" runat="server" ConnectionString="<%$ ConnectionStrings:TimeTrackerConnectionString %>"
                        SelectCommand="SELECT * FROM [Unite_TimeSheet]"
                        updatecommand="UPDATE [Unite_TimeSheet]
                        SET  PlantId=@PlantId                        
                        WHERE TimesheetId=@TimeSheetId">
                        <asp:SqlDataSource ID="Plant" runat="server" ConnectionString="<%$ ConnectionStrings:TimeTrackerConnectionString %>"
                        SelectCommand="SELECT PlantId,description,Code FROM [Unite_Plant]"></asp:SqlDataSource>