I have a repeater that has a placeholder inside it. I am assigning a datalist to the placehoder and setting the datasource inside the itemdatabound of the repeater. I also have a need to so some decision making inside the itemdatabound of the datalist. How do I hook up an ItemDataBound sub to a nested datalist?
<asp:Repeater ID="stepRepeater" Runat="server">
<ItemTemplate>
<tr>
<td align="center" width="5%" style="font-size:8pt;font-family:Arial;"><asp:Label ID="stepLabel" runat="server"/></td>
<td width="95%">
<asplaceholder ID="oPlaceHolder" Runat="server">
</asplaceholder>
</td>
</tr>
</ItemTemplate>
</asp:Repeater>
Private Sub stepRepeater_ItemDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.RepeaterItemEventArgs) Handles stepRepeater.ItemDataBound
Dim stepLabel As Label = CType(e.Item.FindControl("stepLabel"), Label)
Dim oPlaceHolder As PlaceHolder = CType(e.Item.FindControl("oPlaceHolder"), PlaceHolder)
If e.Item.ItemType = ListItemType.AlternatingItem Or e.Item.ItemType = ListItemType.Item Then
stepLabel.Text = "<b>Step " & e.Item.DataItem("EntStep") & "</b><br>"
stepLabel.Text += "Choose <br>"
stepLabel.Text += "<b>" & Replace(e.Item.DataItem("EntOptionType"), "_", " ") & "</b>"
Dim thisList As New DataList
Dim oSQL As String
oSQL = "Exec getMeSomeData "
Dim oCommand As New OdbcCommand(oSQL, dbConn2)
Dim oReader As OdbcDataReader
oReader = oCommand.ExecuteReader
thisList.DataSource = oReader
thisList.DataBind()
'HOW DO I HOOK thisList to the ItemDataBound
'FUNCTION BELOW
oPlaceHolder.Controls.Add(thisList)
oReader.Close()
End If
End Sub
Private Sub thisList_ItemDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.DataListItemEventArgs) Handles thisList.ItemDataBound
'NOTE: THE HANDLES THISLIST.ITEMDATABOUND gives an error.
End Sub
<asp:Repeater ID="stepRepeater" Runat="server">
<ItemTemplate>
<tr>
<td align="center" width="5%" style="font-size:8pt;font-family:Arial;"><asp:Label ID="stepLabel" runat="server"/></td>
<td width="95%">
<asplaceholder ID="oPlaceHolder" Runat="server">
</asplaceholder>
</td>
</tr>
</ItemTemplate>
</asp:Repeater>
Private Sub stepRepeater_ItemDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.RepeaterItemEventArgs) Handles stepRepeater.ItemDataBound
Dim stepLabel As Label = CType(e.Item.FindControl("stepLabel"), Label)
Dim oPlaceHolder As PlaceHolder = CType(e.Item.FindControl("oPlaceHolder"), PlaceHolder)
If e.Item.ItemType = ListItemType.AlternatingItem Or e.Item.ItemType = ListItemType.Item Then
stepLabel.Text = "<b>Step " & e.Item.DataItem("EntStep") & "</b><br>"
stepLabel.Text += "Choose <br>"
stepLabel.Text += "<b>" & Replace(e.Item.DataItem("EntOptionType"), "_", " ") & "</b>"
Dim thisList As New DataList
Dim oSQL As String
oSQL = "Exec getMeSomeData "
Dim oCommand As New OdbcCommand(oSQL, dbConn2)
Dim oReader As OdbcDataReader
oReader = oCommand.ExecuteReader
thisList.DataSource = oReader
thisList.DataBind()
'HOW DO I HOOK thisList to the ItemDataBound
'FUNCTION BELOW
oPlaceHolder.Controls.Add(thisList)
oReader.Close()
End If
End Sub
Private Sub thisList_ItemDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.DataListItemEventArgs) Handles thisList.ItemDataBound
'NOTE: THE HANDLES THISLIST.ITEMDATABOUND gives an error.
End Sub