.Net 3.5, VB
I have a datalist which contains a list of contacts, and in the header template I specify the header columns for the labels and then have a table in the item template.
What I have to do is hardcode the width of the columns in both the header and the item template so they are the same, is there any way on loading of the table to extract the width of the column and then apply this to the relevant column in the header?
The current code is below:
<
asp:DataList ID="dlContacts" runat="server">
<ItemStyle CssClass="DataListLineStyle" />
<AlternatingItemStyle CssClass="DataListAlternatingLineStyle" />
<HeaderTemplate>
<table class="Table" border="0" cellpadding="0" cellspacing="0">
<tr>
<td colspan="6" class="CellHeader">
Customer Contacts
</td>
</tr>
<tr class="CellLabel">
<td width="150px" align="left">
Name
</td>
<td width="100px" align="center">
Title
</td>
<td width="125px" align="center">
Office Tel
</td>
<td width="125px" align="center">
Mobile
</td>
<td width="175px" align="center">
Email
</td>
<td width="125px" align="center">
Fax
</td>
</tr>
</table>
</HeaderTemplate>
<ItemTemplate>
<table width="100%" class="Table" cellpadding="0" cellspacing="0" border="0">
<tr>
<td width="150px" align="left">
<asp:TextBox ID="txtContact" runat="server" Text='<%# Eval("CUS_CONTACT") %>' Width="10px" Visible="False" CssClass="TextBoxDisplayCenterAlign"></asp:TextBox><asp:LinkButton ID="lbContactName" runat="server"
Text='<%# Eval("NAME") %>' CssClass="LinkButtonDisplayLeftAlign"
CommandName="Select" Width="150px"></asp:LinkButton>
</td>
<td width="100px" align="center">
<asp:TextBox ID="txtContactJobTitle" runat="server" Text='<%# Eval("TITLE") %>' Width="100px" CssClass="TextBoxDisplayCenterAlign"></asp:TextBox>
</td>
<td width="125px" align="center">
<asp:TextBox ID="txtContactTel" runat="server" Text='<%# Eval("TEL_OFFICE") %>' Width="125px" CssClass="TextBoxDisplayCenterAlign"></asp:TextBox>
</td>
<td width="125px" align="center">
<asp:TextBox ID="txtContactMobile" runat="server" Text='<%# Eval("TEL_MOBILE") %>' Width="125px" CssClass="TextBoxDisplayCenterAlign"></asp:TextBox>
</td>
<td width="175px" align="center">
<asp:TextBox ID="txtContactEmail" runat="server" Text='<%# Eval("EMAIL") %>' Width="175px" CssClass="TextBoxDisplayCenterAlign"></asp:TextBox>
</td>
<td width="125px" align="center">
<asp:TextBox ID="txtContactFax" runat="server" Text='<%# Eval("FAX") %>' Width="125px" CssClass="TextBoxDisplayCenterAlign"></asp:TextBox>
</td>
</tr>
</table>
</ItemTemplate>
</asp:DataList>