ASPX:
<asp:Repeater ID="rptOuter" runat="server" OnItemDataBound="rptOuter_ItemDataBound">
<HeaderTemplate>
<ul style="list-style-type: none">
</HeaderTemplate>
<ItemTemplate>
<li id='<%# Eval("Id") %>'>
<%# Eval("Category") %>
<asp:Repeater ID="rptInner" runat="server">
<HeaderTemplate>
<ul style="list-style-type: none">
</HeaderTemplate>
<ItemTemplate>
<li>
<asp:CheckBox ID="chkFeed" runat="server" Text='<%# Eval("Feed") %>' />
</li>
</ItemTemplate>
<FooterTemplate>
</ul>
</FooterTemplate>
</asp:Repeater>
</li>
</ItemTemplate>
<FooterTemplate>
</ul>
</FooterTemplate>
</asp:Repeater>
Code Behind:protected void Page_Load(object sender, EventArgs e)
{
using (SqlConnection conn = new SqlConnection(connString))
{
conn.Open();
SqlCommand cmd = new SqlCommand("SELECT id, category FROM rsscategory_tbl", conn);
SqlDataReader rdr = cmd.ExecuteReader();
this.rptOuter.DataSource = rdr;
this.rptOuter.DataBind();
rdr.Close();
}
}
protected void rptOuter_ItemDataBound(object sender, RepeaterItemEventArgs e)
{
if (e.Item.ItemType == ListItemType.Item ||
e.Item.ItemType == ListItemType.AlternatingItem)
{
using (SqlConnection conn = new SqlConnection(connString))
{
conn.Open();
System.Data.Common.DbDataRecord rd = (System.Data.Common.DbDataRecord)e.Item.DataItem;
SqlCommand cmd = new SqlCommand("SELECT feed FROM rssfeed_tbl WHERE categoryid = " + rd.GetInt32(rd.GetOrdinal("id")), conn);
Repeater rptInner = (Repeater)e.Item.FindControl("rptInner");
SqlDataReader rdr = cmd.ExecuteReader();
rptInner.DataSource = rdr;
rptInner.DataBind();
rdr.Close();
}
}
}