Dynamically set datagrid HeaderText
I am creating a ASP .Net page to maintain all of my lookup tables, rather than creating a separate page for every 2-4 field table.
Initially I thought I would change the headertext property during the datagrids OnItemDataBound event, checking for ListItemType.Header, etc. This proved a bit convoluted with the resolution being much simpler:
dgrLookupTable.Columns(1).HeaderText = "Source"
The ASP code looks like this:
<asp:TemplateColumn SortExpression="1" HeaderText="">
<HeaderStyle Width="150px"></HeaderStyle>
<ItemStyle Wrap="False"></ItemStyle>
<ItemTemplate>
<span class="dgrOverflow">
<%#Container.DataItem("1")%>
</span>
</ItemTemplate>
<EditItemTemplate>
<ASP:TextBox Size="40" id="txt1" Text='<%# Container.DataItem("1")%>' runat="server" />
</EditItemTemplate>
</asp:TemplateColumn>
- Download this code: DynamicHeaders.txt
Trackback URI |