Multiple repeater nested use

Source: Internet
Author: User

<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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.