后台代码:

private void bindnewslist()
    {
        long num = 100L;
        List<Model.news> news = _news.GetList(out num);
        this.newslist.DataSource = news;
        this.newslist.DataBind();
    }

 

说明:Model.news是实体类,GetList(out long)方法返回List<Model.news>.

前台代码:

<ul class="dot">
             <asp:Repeater ID="newslist" runat="server" >
               <ItemTemplate>
                 <li><a href="#"><%# (Container.DataItem as Model.news).title %></a></li>
               </ItemTemplate>
             </asp:Repeater>
</ul>

 

说明:title为实体类Model.news的一个属性。

另绑定List<string>时直接用Container.DataItem 即可。

相关文章:

  • 2022-01-23
  • 2021-11-20
  • 2022-03-04
  • 2022-12-23
  • 2022-02-26
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-08-11
  • 2022-12-23
  • 2021-07-23
  • 2021-12-02
  • 2022-03-08
相关资源
相似解决方案