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 }