Hi dharmendr.
I have a simple query that joins two tables.
The first table is "vendors". This table contains two fields that are populated using data from another database table called "unitTypes" because each mailing address can contain two unit types (i.e. Building A, Floor 2).
The table "unitTypes" contains two fields, "unitId" and "unitType". unitId is stored in the "vendors" table in two fields, "venUnitType" and "venUnitTypeTwo".
Notice that in the SELECT statement of the query I have "v.venUnitType" and "v.venUnitTypeTwo", each of which store the integer associated with corresponding "unitType" found in the "unitTypes" table. So to display the value instead of the integer I joined to the "unitTypes" table twice and added "ut.unitType" and "ut2.unitType". These two fields provide the value instead of the integer.
The query works just fine. But the issue occurs when I try to modify the ItemTemplate of the formview to display the values instead of the integers. The issue is because both unit type fields get their data from the same source table and field. So, I assumed I should use the table alias in the data binding of the label, but that's when it stops working. Here are the two Labels:
<asp:Label Text='<%# Bind("ut.unitType") %>' runat="server" ID="venUnitTypeLabel" />
<asp:Label Text='<%# Bind("ut2.unitType") %>' runat="server" ID="venUnitTypeTwoLabel" />
As a short-term solution I added a third table that contains unit types as well. I just gave it a different name and titled the fields differently. Then I modified the query and labels of the ItemTemplate. It works great, but it's not a very elegant solution.
Any help is greatly appreciated.
Thanks,
jferg