Use the Repeater control and mvcrepeater in Asp. Net MVC.

Source: Internet
Author: User

Use the Repeater control and mvcrepeater in Asp. Net MVC.

Use the Repeater control to display chart information in the view. Repeater control usage Overview:

<Asp: Repeater ID = "Repeater1" runat = "server"> </asp: Repeater>

1. Bind data

<%

This. Repeater1.DataSource = Model; <-- specify the data source -->

This. Repeater1.DataBlind (); <-- bind -->

%>

2. Control Composition

<HeaderTemplate> </HeaderTemplate> <-- header -->

<ItemTemplate> </ItemTemplate> <-- subject part -->

<FooterTemplate> </FooterTemplate> <-- tail -->

3. Eval () method

<% # Eval ("Name") %> <-- Name attribute of the object in the data source -->

 

Sample Code:

<% -- Bind data source -- %> <% this. friInfoList. dataSource = Model; this. friInfoList. dataBind (); %> <asp: repeater ID = "FriInfoList" runat = "server"> <% -- header -- %> <HeaderTemplate> <table border = "1" cellpadding = "5" cellspacing = "0"> <thead> <tr> <td> name </td> <td> link </td> <td> phone number </td> <td> address </td>/ tr> </thead> </HeaderTemplate> <% -- subject item -- %> <ItemTemplate> <tbody> <tr> <td> <% # Eval ("Name ") %> </td> <% # Eval ("Relation") %> </td> <% # Eval ("Phone ") %> </td> <% # Eval ("Address ") %> </td> </tr> </tbody> </ItemTemplate> <% -- tail -- %> <FooterTemplate> </table> </FooterTemplate> </asp: repeater>

Running result:

 

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.