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
                            
                        
                    
                
                                已关闭8年。
            
                    
我有这样的课

    public class Link
    {
        public string LinkID { get; set; }
        public string Title { get; set; }
        public string URL { get; set; }
    }


和一个返回Link[]数组的方法

我可以将其绑定到转发器,该转发器将引用链接中的标题和URL吗?
如何引用? <%# DataBinder.Eval(Container.DataItem, "Title") %>没有显示任何内容

编辑:这很尴尬。.我忘记了几天前我清空了数据库

最佳答案

确保设置数据源,然后设置绑定:

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


绑定所有内容后,您可以在转发器中引用这些项目:

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


要么

<%# Eval( "Title" ) %>

关于c# - 如何将转发器绑定(bind)到自定义类的数组? ,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/7224571/

10-10 19:55