Repeater creates complex Headers

Source: Internet
Author: User

Repeater creates a table Article index for a complex table header: 0 csdn blog introduces the article index concept. The article index is calculated based on the comprehensive score of the blog article. The comprehensive score items are the clicks of the article, respectively, number of replies, number of indexed articles, Article length, and Article type; out of 100, updated every month.
Although the function of the gridview is powerful, it is inferior in creating complex table header reports. Now we should think of another control: repeater. The repeater structure is as follows:

// QQ: 272912705 wings www.hi.baidu.com/jcomet
<Asp: repeater id = "repeater1" runat = "server">
<Headertemplate>
</Headertemplate>
<Itemtemplate>
</Itemtemplate>
<Alternatingitemtemplate>
</Alternatingitemtemplate>
<Footertemplate>
</Footertemplate>
</ASP: repeater>
As the name suggests, headertemplate is the header template, itemtemplate is a repeated item, alternatingitemtemplate is a repeated alternative item, and footertemplate is the footer part.
The following is an example:

1. Front-end code:
<Asp: repeater id = "repeater1" runat = "server">
<Headertemplate>
<Table border = "1" align = "center" width = "100%" bordercolorlight = "# a9a9a9" bordercolordark = "# ffffff"
Cellspacing = "0" cellpadding = "1" bordercolor = "# a9a9a9" style = "text-align: center;">
<Tr bgcolor = "# b5dbff">
<TD rowspan = "2" style = "width: 100px">
Band </TD>
<TD rowspan = "2" style = "width: 100px">
Time period </TD>
<TD colspan = "3" style = "height: 17px;">
Part 1 </TD>
<TD colspan = "3" style = "height: 17px;">
Part 2 </TD>
<TD rowspan = "2" style = "width: 100px">
Total </TD>
</Tr>
<Tr bgcolor = "# b5dbff">
<TD style = "width: 100px; Height: 17px;">
1 </TD>
<TD style = "width: 100px; Height: 17px;">
II </TD>
<TD style = "width: 100px; Height: 17px;">
3 </TD>
<TD style = "width: 100px; Height: 17px;">
IV </TD>
<TD style = "width: 100px; Height: 17px;">
5 </TD>
<TD style = "width: 100px; Height: 17px;">
VI </TD>
</Tr>
</Headertemplate>
<Itemtemplate>
<Tr>
<TD style = "width: 100px">
<% # Eval ("channelid") %>
</TD>
<TD style = "width: 100px">
<% # Eval ("time") %>
</TD>
<TD style = "width: 100px">
<% # Eval ("Monday") %>
</TD>
<TD style = "width: 100px">
<% # Eval ("Tuesday") %>
</TD>
<TD style = "width: 100px">
<% # Eval ("Wednesday") %>
</TD>
<TD style = "width: 100px">
<% # Eval ("Thursday") %>
</TD>
<TD style = "width: 100px">
<% # Eval ("Friday") %>
</TD>
<TD style = "width: 100px">
<% # Eval ("Saturday") %>
</TD>
<TD style = "width: 100px">
<% # Eval ("Sunday") %>
</TD>
</Tr>
</Itemtemplate>
<Alternatingitemtemplate>
<Tr style = "background-color: whitesmoke;">
<TD style = "width: 100px">
<% # Eval ("channelid") %>
</TD>
<TD style = "width: 100px">
<% # Eval ("time") %>
</TD>
<TD style = "width: 100px">
<% # Eval ("Monday") %>
</TD>
<TD style = "width: 100px">
<% # Eval ("Tuesday") %>
</TD>
<TD style = "width: 100px">
<% # Eval ("Wednesday") %>
</TD>
<TD style = "width: 100px">
<% # Eval ("Thursday") %>
</TD>
<TD style = "width: 100px">
<% # Eval ("Friday") %>
</TD>
<TD style = "width: 100px">
<% # Eval ("Saturday") %>
</TD>
<TD style = "width: 100px">
<% # Eval ("Sunday") %>
</TD>
</Tr>
</Alternatingitemtemplate>
<Footertemplate>
</Table>
</Footertemplate>
</ASP: repeater>
<PC3: webpager id = "webpager1" runat = "server" pagerstyle = "nextprev" controltopaginate = "repeater1"
Itemsperpage = "24" onpageindexchanged = "webpager1_pageindexchanged"/>
2. Background code:
Page event # region page event
Datatest. BLL. getdata mybiz = new datatest. BLL. getdata ();
Protected void page_load (Object sender, eventargs E)
...{
If (! Page. ispostback)
...{
Getdata ();
Bindgrid ();
}
}
# Endregion

Repeater # region Repeater

Data Binding # region Data Binding
/** // <Summary>
/// Obtain data
/// </Summary>
Protected void getdata ()
...{
This. datasource = mybiz. getorderdetails ("rm_clocks ");;
}

/** // <Summary>
/// Gridview Data Binding
/// </Summary>
Private void bindgrid ()
...{
Webpager1.datasource = This. datasource;
Webpager1.databind ();
}
# Endregion

Page # region page
Protected void webpager1_pageindexchanged (Object sender, WF. webpager. pagechangedeventargs E)
...{
Webpager1.currentpageindex = E. newpageindex;
Webpager1.datasource = This. datasource;
Webpager1.databind ();
}
# Endregion

# Endregion

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.