Using ItemType for strongly typed repeater control?

前端 未结 1 834
盖世英雄少女心
盖世英雄少女心 2020-12-20 13:14

Okay, so I looked up some cool stuff about strongly typed repeater controls... the only issue is that it won\'t work. I have a List that I\'ve boun

相关标签:
1条回答
  • 2020-12-20 13:46

    You need to bind data in code behind like below:

    using (MicroGOVEntities entities = DataEntitiesFactory.GetInstance())
    {
        var getGovernments = from g in entities.S_Government 
                             orderby g.DateCreated descending 
                             select g;
        rpData.DataSource = getGovernments.ToList();
    }
    rpData.DataBind();
    

    And the ASP.NET code is:

    <asp:Repeater ID="rpData" runat="server"
                  ItemType="MicroGOV.Entity.S_Government" 
                  OnItemCommand="rpData_ItemCommand">
        <ItemTemplate>
            <td><%#:Item.GovernmentID %></td>
        </ItemTemplate>
    </asp:Repeater>
    
    0 讨论(0)
提交回复
热议问题