开发者

How to bind a repeater to an array of a custom class? [closed]

This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment in time, or an extraordinarily narrow situation that is not generally applicable to the worldwide audience of the internet. For help making this question more broadly applicable, visit the help center. Closed 11 years ago.

I have a class like this

    public class Link
    {
        public string LinkID { get; set; }
        public string Title { 开发者_开发知识库get; set; }
        public string URL { get; set; }
    }

and a method that returns an array of Link[]

Could I bind that to a repeater, which will reference the Title and URL from Link?

How do I reference it? <%# DataBinder.Eval(Container.DataItem, "Title") %> doesn't make anything show up

edit:This is embarrassing..I forgot that I emptied the database a couple days ago


Make sure you are setting your DataSource and then Binding:

YourRepeater.DataSource = GetArray();
YourRepeater.DataBind();

Once everything is bound, you can reference the items in your repeater:

<%# DataBinder.Eval( Container.DataItem, "Title" ) %>

or

<%# Eval( "Title" ) %>


assuming that your are properly binding your array of Link objects to the repeater, this should work:

<%# DataBinder.Eval(Container.DataItem, "Link.Title") %>
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜