数据绑定只能绑定属性值?
今天工作时用到了repeater控件的绑定,发现一个问题.
我在repeater上绑定了一个reply数组,结果发现在reply类中把body定义成属性可以读取,定义成public变量就不行.下面代码中的Body属性可以在repeater中绑定,public的Email,UserName却不行.
因为学DotNet的时间还很短,一时不能理解.
public class Reply
{
public int ID;
public string Email,UserName,DateAndTime;
private string body;
public Reply()
{
}
public void Show(SqlDataReader dr)
{
this.ID = (int)dr["bbsid"];
this.Email = (string)dr["email"];
this.UserName = (string)dr["username"];
this.Body = (string)dr["body"];
this.DateAndTime = (string)dr["dateandtime"].ToString();
}
public string Body
{
get
{
return body;
}
set
{
body = value;
}
}
}

浙公网安备 33010602011771号