ASP.NET Repeater bind List

前端 未结 7 447
遇见更好的自我
遇见更好的自我 2020-12-04 20:50

I am binding a List to a Repeater control. Now I want to use the Eval function to display the contents in ItemTemplate

7条回答
  •  旧巷少年郎
    2020-12-04 21:20

    A more complete example based on the LINQ provided by @RobertoBr:

    In code behind:

    List notes = new List();
    notes.Add("Value1")
    notes.Add("Value2")
    
    repeaterControl1.DataSource = from c in notes select new {NAME = c};
    repeaterControl1.DataBind();
    

    On page:

       
        
            
  • <%# Eval("NAME") %>
提交回复
热议问题