i have a requirement to access a Label control that sits in the GroupTemplate.
the issue for me, resides in the ItemDataBound event of the RadListView.
when i FindControl for "lblFileName", which sits in the ItemTemplate, it finds it OK.
but when i FindControl for "lblHeader", which sits in the GroupTemplate, it can't find it.
my desire is to have a different Group Header Label for each individual Group. This Label will be programatically created so it is not possible to know what it would be before the Page Loads.
My HTML is:
the issue for me, resides in the ItemDataBound event of the RadListView.
when i FindControl for "lblFileName", which sits in the ItemTemplate, it finds it OK.
but when i FindControl for "lblHeader", which sits in the GroupTemplate, it can't find it.
my desire is to have a different Group Header Label for each individual Group. This Label will be programatically created so it is not possible to know what it would be before the Page Loads.
My HTML is:
<telerik:RadListView ItemPlaceholderID="plItemHolder" GroupPlaceholderID="plGroupHolder" runat="server" ID="lstCSV"> <LayoutTemplate> <asp:PlaceHolder runat="server" ID="plGroupHolder"></asp:PlaceHolder> </LayoutTemplate> <GroupTemplate> <asp:Label ID="lblHeader" runat="server" Text="<h3>hello world</h3>"></asp:Label> <asp:PlaceHolder runat="server" ID="plItemHolder"></asp:PlaceHolder> </GroupTemplate> <ItemTemplate> <table> <tr> <td> <asp:Label runat="server" ID="lblFileName"></asp:Label> </td> </tr> </table> </ItemTemplate> </telerik:RadListView>
i am then calling the following Method to Bind to my RadListView
Private Sub getFileNames()
Dim di As New DirectoryInfo(Server.MapPath(uploadCSV.TargetFolder))
Dim diar1 As FileInfo() = di.GetFiles()
lstCSV.DataSource = diar1
lstCSV.DataBind()
End Sub
finally, i have the following in the ItemDataBOund event of the RadListView
Private Sub lstCSV_ItemDataBound(sender As Object, e As RadListViewItemEventArgs) Handles lstCSV.ItemDataBound
Dim lblFileName As New Label
Dim lblHeaderName As New Label
Dim tempHeaderName As String = String.Empty
lblFileName.Text = TryCast(TryCast(e.Item, RadListViewDataItem).DataItem, FileSystemInfo).Name
Dim s As String() = uploadCSV.AllowedFileExtensions
For i As Integer = 0 To s.Length - 1
If tempHeaderName = String.Empty Then
tempHeaderName = lblFileName.Text.Replace("." + s(i).ToString, "")
Else
tempHeaderName = tempHeaderName.Replace("." + s(i).ToString, "")
End If
Next
Dim lblBindName As New Label
Dim lblBindHeader As New Label
lblBindName = e.Item.FindControl("lblFileName")
lblBindHeader = e.Item.FindControl("lblHeader")
If Not IsNothing(lblBindName) Then lblBindName.Text = lblFileName.Text
If Not IsNothing(lblBindHeader) Then lblBindHeader.Text = tempHeaderName
End Sub
