开发者

Bind a repeater to an object

In my page_load I have called an object and am trying to bind it to a repeater, like so:

TestProgram myProgram = new TestProgram("5");

program_list.DataSource = myProgram;开发者_JAVA百科
program_list.DataBind();

and my repeater looks like

<asp:Repeater id="program_list" runat="server"> 
    <ItemTemplate>
        <%# Eval("status").ToString().Trim() %>
     </ItemTemplate>
</asp:Repeater>

Any idea why it isn't working?


The datasource has to be a collection-type.

Try using a list.

TestProgram myProgram = new TestProgram("5");

List<TestProgram> programs = new List<TestProgram>{myProgram};

program_list.DataSource = programs;
program_list.DataBind();
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜