<ul>
<asp:repeater id= "Bclass" runat= "Server" onitemdatabound= "Bclasslist";
<itemtemplate
<li>
<div><% #Eval ("X_classname")%></div>
<asp:repeater id= "Bsclass "runat=" Server "onitemdatabound=" bsclasslist "
<HeaderTemplate><ul></HeaderTemplate>
<footertemplate></ul></footertemplate>
<itemtemplate>
<li>
<div ><% #Eval ("X_classname")%></div>
<asp:repeater id= "Sclass" runat= "Server";
< Headertemplate><ul> <footertemplate></ul></footertemplate
<itemtemplate>
<li>
<div><% #Eval ("X_classname")%></div>
</li
</itemtemplate>
</asp:repeater>
</li>
</itemtemplate>
</asp : Repeater>
</li>
</itemtemplate>
</asp:repeater>
</ul>
Cs:
protected void Page_Load (object sender, EventArgs e)
{
if (session["login"] = = null)
{
Response.Redirect ("Login.aspx");
Response.End ();
}
OleDbConnection conn = Dbopen.getdb ();
String bStr = "Select Id,x_classname,taxis,preid fromtable where preid=0 order by taxis asc,id ASC";
OleDbDataAdapter rs = new OleDbDataAdapter (bstr,conn);
Conn. Open ();
DataSet rd = new DataSet ();
Rs. Fill (RD);
Bclass.datasource = rd;
Bclass.databind ();
Conn. Close ();
}
protected void Bclasslist (Objectsender, RepeaterItemEventArgs e)
{
if (E.item.itemtype = = ListItemType.Item | | e.item.itemtype ==listitemtype.alternatingitem)
{
String Preid = ((DataRowView) e.item.dataitem). row["id"]. ToString ();//get the corresponding ID
Repeater Bsclass = (Repeater) e.item.findcontrol ("Bsclass");//Find the Repeater to bind data to
if (bsclass! = null)
{
OleDbConnection sc = Dbopen.getdb ();
string sSQL = "Select Id,x_classname,taxis,preid from Table wherepreid=" +preid+ "ORDER by taxis asc,id ASC";
OleDbDataAdapter SRS = new OleDbDataAdapter (SSQL,SC);
Sc. Open ();
DataSet SRD = new DataSet ();
Srs. Fill (SRD);
Bsclass.datasource = SRD;
Bsclass.databind ();
Sc. Close ();
}
}
}
protected void Bsclasslist (Objectsender,repeateritemeventargs e)
{
if (E.item.itemtype = = ListItemType.Item | | e.item.itemtype ==listitemtype.alternatingitem)
{
String Preid = ((DataRowView) e.item.dataitem). row["id"]. ToString ();//get the corresponding ID
Repeater Sclass = (Repeater) e.item.findcontrol ("Sclass");//Find the Repeater to bind data to
if (sclass! = null)
{
OleDbConnection sc = Dbopen.getdb ();
string sSQL = "Select Id,x_classname,taxis,preid from Table wherepreid=" + Preid + "ORDER by taxis asc,id ASC";
OleDbDataAdapter SRS = new OleDbDataAdapter (sSQL, SC);
Sc. Open ();
DataSet SRD = new DataSet ();
Srs. Fill (SRD);
Sclass.datasource = SRD;
Sclass.databind ();
Sc. Close ();
}
}
}
Multiple repeater nested use