How to get to controls inside DataList?
I have a datalist that has four labels. The text property of these labels are bound to personalized functions (see below). How can I get access to the controls inside the DataList (the labels) so that I can add them to another control to render to Excel?
My DataList:
<asp:DataList ID="DataList2" runat="server" DataSourceID="KnightsDataSource1">
<HeaderTemplate>
<div style="width:60px; float:left"><asp:Label ID="Label5" runat="server" Text="" Font-Bold="true" Font-Underline="true" ></asp:Label></div>
<div style ="width:60px; float:left"><asp:Label ID="Label7" runat="server" Text="" Font-Bold="true" Font-Underline="true" ></asp:Label></div>
<div style ="width:40px; float:left"><asp:Label ID="Label8" runat="server" Text="Hrs" Font-Bold="true" Font-Underline="true" ></asp:Label></div>
<div style="width:40px; float:left"><asp:Label ID="Label9" runat="server" Text="Mins" Font-Bold="true" Font-Underline="true" ></asp:Label></div>
</HeaderTemplate>
<ItemTemplate>
<div style="clear:left; float:left; width:60px"><asp:Label ID="Label3" runat="server" Text='<%# Bind("fname") %>'></asp:Label></div>
<div style="float:left; width:60px"><asp:Label ID="Label7" runat="server" Text='<%# Bind("lname") %>' ></asp:Label></div>
<div style="float:left; width:40px"><asp:Label ID="Label6" runat="server" Text='<%# EventStruct.CalculateHours(Eval("total")) %>'></asp:Label></div>
<div style="float:left; width:40px"><asp:Label ID="Label1" runat="server" Text='<%# EventStruct.CalculateMinutes(Eval("total")) %>'></asp:Label> </div>
</ItemTemplate>
</asp:DataList>
Functions:
Public Shared Function CalculateHours(ByVal total As Object) As Integer
Dim returnInt As Integer = 0
If total IsNot DBNull.Value Then
returnInt = (total / 60) - 0.5
End If
Return returnInt
End Function
Public Shared Function CalculateMinutes(ByVal total As Object) As Integer
Dim returnInt As Integer = 0
If total IsNot DBNull.Value Then
returnInt = total Mod 60
End If
Return returnInt
End Function
|