클래스를 선언했지만 멤버에 액세스하려고하면 다음 오류가 표시됩니다.
DataBinding : 'reapTest.Toop'에 'Rang'이라는 속성이 없습니다.DataBinding에서 존재하는 속성을 찾을 수없는 이유는 무엇입니까?
다음 WebForm1.aspx.cs :
namespace reapTest {
public class Toop {
public string Rang;
public int Gheymat;
}
public static class MyData {
public static Toop[] TP = new Toop[] { new Toop() { Rang = "Ghermez", Gheymat = 100 }, new Toop() { Rang = "Yellow", Gheymat = 44 } };
public static Toop[] RT() {
return TP;
}
}
public partial class WebForm1 : System.Web.UI.Page {
protected void Page_Load(object sender, EventArgs e) {
}
}
}
WebForm1.aspx를 :
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm1.aspx.cs" Inherits="reapTest.WebForm1" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:Repeater ID="Repeater1" runat="server" DataSourceID="ObjectDataSource1">
<ItemTemplate>
<%#Eval("Rang")%>
</ItemTemplate>
</asp:Repeater>
<asp:ObjectDataSource runat="server" ID="ObjectDataSource1" SelectMethod="RT" TypeName="reapTest.MyData"></asp:ObjectDataSource>
</div>
</form>
</body>
</html>
저는 Rang이라는 * 리터럴 * 속성을 찾고 있기 때문에 그것이라고 생각합니다. Rang이라는 필드가 있지만 속성과 동일하지 않습니다. 그냥 생각. –
@David, 그 생각은 좋은 대답을 만들 것입니다 :) –
@DavidW 놀라운 것은 내가 처음으로 웹 사이트를 운영했을 때 그것을 작동시킬 수 있다는 것입니다. 바로 다음에 오류가 컴파일 된 후 .. –