Thank you for the response Phillip. I am new to Repeaters and DataLists, and
am encountering an error when using the code provided. The FindControl is
failing. Do you see something wrong with what I am doing? Below is the
code. Thanks again,
Erik
HTML:
<asp:Repeater id="DetailRepeater" runat="server">
<ItemTemplate>
<asp
ataList id="dlstDetail" runat="server"></asp
ataList>
</ItemTemplate>
</asp:Repeater>
VB.Net:
Private Sub DetailRepeater_ItemDataBound(ByVal sender As Object, ByVal e
As System.Web.UI.WebControls.RepeaterItemEventArgs) Handles
DetailRepeater.ItemDataBound
If e.Item.ItemType = ListItemType.Item Then
Dim dl As DataList
dl = New DataList
dl = e.Item.FindControl("dlstDetail")
If Not dl Is Nothing Then
'write code to assign the datasource for the datalist
dl.ItemTemplate = New DatalistLabelColumn
dl.DataSource = oData.Tables(0).DefaultView
dl.DataBind()
End If
End If
End Sub
Public Class DatalistLabelColumn
Implements ITemplate
Public Sub InstantiateIn(ByVal container As Control) Implements
System.Web.UI.ITemplate.InstantiateIn
Dim label1 As New Label
AddHandler label1.DataBinding, AddressOf Me.BindLabelColumn
container.Controls.Add(label1)
End Sub 'InstantiateIn
Public Sub BindLabelColumn(ByVal sender As Object, ByVal e As
EventArgs)
Dim lbl As Label = CType(sender, Label)
Dim container As DataListItem = CType(lbl.NamingContainer,
DataListItem)
Dim strVals As String = "<tr><td>" +
Convert.ToString(DataBinder.Eval(CType(container, DataListItem).DataItem,
"CustomerNo")) + "</td>" + _
"<td>" + Convert.ToString(DataBinder.Eval(CType(container,
DataListItem).DataItem, "ContactNo")) + "</td>" + _
"<td>" + Convert.ToString(DataBinder.Eval(CType(container,
DataListItem).DataItem, "CompanyName")) + "</td>" + _
"<td>" + Convert.ToString(DataBinder.Eval(CType(container,
DataListItem).DataItem, "ContactName")) + "</td>" + _
"<td>" + Convert.ToString(DataBinder.Eval(CType(container,
DataListItem).DataItem, "ACTContact.CustomerClass")) + "</td>" + _
"<td>" + Convert.ToString(DataBinder.Eval(CType(container,
DataListItem).DataItem, "Phone")) + "</td>" + _
"<td>" + Convert.ToString(DataBinder.Eval(CType(container,
DataListItem).DataItem, "CallFrequency")) + "</td></tr>"
lbl.Text = strVals
End Sub 'BindLabelColumn
End Class 'DatalistLabelColumn