How to bind the Repeater control to an array and an ArrayList

Source: Internet
Author: User

Front-end code: Copy codeThe Code is as follows: <asp: Repeater ID = "rptarry" runat = "server">
<HeaderTemplate> <table> </HeaderTemplate>
<ItemTemplate>
<Tr> <td> <% # GetDataItem () %> </td> </tr>
</ItemTemplate>
<FooterTemplate> </table> </FooterTemplate>
</Asp: Repeater>
<Asp: Repeater ID = "rptarryList" runat = "server">
<HeaderTemplate> <table> </HeaderTemplate>
<ItemTemplate>
<Tr> <td> <% # GetDataItem () %> </td> </tr>
</ItemTemplate>
<FooterTemplate> </table> </FooterTemplate>
</Asp: Repeater>

Background code:Copy codeThe Code is as follows: public void bindrptarry ()
{
String strs = "li | wen | yuan ";
String [] str = strs. Split ('| ');
Rptarry. DataSource = str;
Rptarry. DataBind ();
}
Public void bindrptarryList ()
{
String strs = "li | wen | yuan ";
String [] str = strs. Split ('| ');
Rptarry. DataSource = arrayList ();
Rptarry. DataBind ();
}
Public ArrayList arrayList ()
{
ArrayList aL = new ArrayList ();
AL. Add ("liceshi ");
AL. Add ("wenceshi ");
AL. Add ("yuanceshi ");
Return aL;
}

Bind the data source (array or ArrayList) with DataSource in the background and call the DataBind () method,
Call <% # GetDataItem () %> at the front end.

If there are any errors, you are welcome to criticize and correct them and make progress together.

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.