“DataBinding: 'index+NewsItem' does not contain a property with the name 'Link'”, but property exists (Not a Typo)

后端 未结 1 1307
爱一瞬间的悲伤
爱一瞬间的悲伤 2021-01-03 22:01

First I have a repeater, and I\'m outputting a property. I have tried both

<%#Eval(\"Link\")%>

and

<%#DataBinde         


        
相关标签:
1条回答
  • 2021-01-03 22:29

    You have created fields, not properties

    To turn them into properties, adjust your code like this

    public class NewsItem  
    {  
         public string Link { get; set; }
         public string Title { get; set; }              
    
         public NewsItem()
         {
               this.Link = string.Empty;
               this.Title = string.Empty;
         }
    }  
    
    0 讨论(0)
提交回复
热议问题