Data Control-Repeater Data Control

Source: Internet
Author: User

The primary function of the Repeater control is to control data in a more free way and present data in a non-table form. The most important part of the Repeater control is the template, which allows you to define five templates;
1. itemtemplate: a data template, which is required by the Repeater control.
2. alternatingitemtemplate: an optional parameter.
3. separatortemplate, which is an optional parameter.
4. headertemplate: Header template. An optional parameter.
5. footertemplate: End template. Optional.

<Asp: repeater id = "Rep" runat = "server">
<Itemtemplate>
<B>
<% # Databinder. eval (container. dataitem, "name") %>
(<% # Databinder. eval (container. dataitem, "student ID") %>) </B>
Mathematical score: <% # databinder. eval (container. dataitem, "Mathematics") %> <br>
</Itemtemplate>
</ASP: repeater>

Protected void page_load (Object sender, eventargs E)
{
String provider, database, connstr, SQL;
Provider = "Microsoft. Jet. oledb.4.0 ;";
Database = server. mappath ("person. mdb ");
Connstr = "provider =" + provider + "Data Source =" + database;
SQL = "select * from Grade ";
Oledbdataadapter da;
DA = new oledbdataadapter (SQL, connstr );
Dataset DS = new dataset ();
Da. Fill (DS, "Grade ");
Rep. datasource = Ds. Tables ["Grade"]. defaultview;
Rep. databind ();
}

You can also use other templates. <Asp: repeater id = "Rep" runat = "server">
<Headertemplate>
First graduates renewal table <p>
</Headertemplate>
<Itemtemplate>
<B>
<% # Databinder. eval (container. dataitem, "name") %>
(<% # Databinder. eval (container. dataitem, "student ID") %>) </B> mathematical score: <% # databinder. eval (container. dataitem, "Mathematics") %> <br>
</Itemtemplate>
<Alternatingitemtemplate>
<Font color = "blue"> <B>
<% # Databinder. eval (container. dataitem, "name") %>
(<% # Databinder. eval (container. dataitem, "student ID") %>) </B> mathematical score: <% # databinder. eval (container. dataitem, "Mathematics") %> <br>
</Font>
</Alternatingitemtemplate>
<Separatortemplate>
<HR width = "80%" align = "Left"/>
</Separatortemplate>
<Footertemplate>
<P>
End now! </Footertemplate>
</ASP: repeater>

Protected void page_load (Object sender, eventargs E)
{
String provider, database, connstr, SQL;
Provider = "Microsoft. Jet. oledb.4.0 ;";
Database = server. mappath ("person. mdb ");
Connstr = "provider =" + provider + "Data Source =" + database;
SQL = "select * from Grade ";
Oledbdataadapter da;
DA = new oledbdataadapter (SQL, connstr );
Dataset DS = new dataset ();
Da. Fill (DS, "Grade ");
Rep. datasource = Ds. Tables ["Grade"]. defaultview;
Rep. databind ();
}

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.