Post) Use repeater to bind custom multi-column data

Source: Internet
Author: User
Many people on the internet asked how to use ASP. net generates multiple columns of tables containing bound data, and some even use response. write ("<Table> </table>"); this old method of generating tables with low performance. In fact, this is done using the server-side table. Now we use repeater to control the custom generation of tables with multiple columns containing bound data.CodeAs follows:
The front-end HTML code is as follows: < ASP: Repeater Runat = "Server" ID = "Repeater1" Onitemdatabound = "Repeaterincluitemdatabound" >
< Headertemplate >
< Table Width = "100%" Border = 0 Align = "Center" > < Tr >
</ Headertemplate >
< Itemtemplate >
< TD > <% # Databinder.Eval(Container. dataitem,"Field name") %> </ TD >
</ Itemtemplate >
< Footertemplate >
</ Tr > </ Table >
</ Footertemplate >
</ ASP: Repeater >

The background code is as follows: 1 // Define global variable I
2 Int I = 0 ;
3 Void Repeaterincluitemdatabound ( Object SRC, repeateritemeventargs E) {
4 If (I % 3 = 0 ) {//3 indicates that the table has three columns.
5E. Item. Controls. Add (NewLiteralcontrol ("</Tr> <tr>"));
6}
7 I ++ ;
8 }

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.