rptziliao 使用的是无效数据源。有效数据源必须实现 IListSource 或 IEnumerable。
数据层public userziliao getUserZiLiaoMessage(int ID)
{
SqlParameter userID = new SqlParameter("@userID", ID);
SqlDataReader dr = DBHelper.GetReader("select UserZiLiao.ZiLiaoID,UserZiLiao.UserID,UserZiLiao.ZiLiaoName,UserZiLiao.ZiLiaoAge,UserZiLiao.ZiLiaoSex,UserZiLiao.ZiLiaoPhone,UserZiLiao.ZiLiaoSite,UserZiLiao.ZiLiaoAihao,UserZiLiao.ShuoMing,Users.UserName,Users.UserImage,UserQuanxian.UserQuanxianName from UserZiLiao join Users on UserZiLiao.UserID=Users.UserID join UserQuanxian on Users.UserID=UserQuanxian.UserZhuangTaiID where UserZiLiao.UserID=@userID", userID);
userziliao zilao = null;
if (dr.Read())
{
zilao = new userziliao();
zilao.ZiLiaoID = dr.GetInt32(0);
zilao.UserID = dr.GetInt32(1);
zilao.ZiLiaoName = dr.GetString(2);
zilao.ZiLiaoAge = dr.GetInt32(3);
zilao.ZiLiaoSex = dr.GetString(4);
zilao.ZiLiaoPhone = dr.GetString(5);
zilao.ZiLiaoSite = dr.GetString(6);
zilao.ZiLiaoAihao = dr.GetString(7);
zilao.ShuoMing = dr.GetString(8);
zilao.UserName = dr.GetString(9);
zilao.UserImage = dr.GetString(10);
zilao.UserQuanxianName = dr.GetString(11);
}
dr.Close();
return zilao;
}
逻辑层:
public userziliao getUserZiLiaoMessage(int ID)
{
return user.getUserZiLiaoMessage(ID);
}
前台:<asp:Repeater ID="rptziliao" runat="server">
<ItemTemplate>
<table>
<tr>
<td>姓名:</td>
<td><%#Eval("UserName")%></td>
<td>年龄:</td>
<td><%#Eval("ZiLiaoAge")%></td>
</tr>
<tr>
<td>性别:</td>
<td><%#Eval("ZiLiaoSex")%></td>
<td>电话:</td>
<td><%#Eval("ZiLiaoPhone")%></td>
</tr>
<tr>
<td>住址:</td>
<td><%#Eval("ZiLiaoSite")%></td>
</tr>
<tr>
<td>爱好:</td>
<td><%#Eval("ZiLiaoAihao")%></td>
</tr>
<tr>
<td>说明:</td>
<td><%#Eval("ShuoMing")%></td>
</tr>
</table>
</ItemTemplate>
</asp:Repeater>
后台:
public void getuserziliao()
{
//获取当前空间的用户的ID
int id = Convert.ToInt32(Request["KJuesrID"]);
this.rptziliao.DataSource = userm.getUserZiLiaoMessage(id);
this.rptziliao.DataBind();
}
我根本就看不出是什么错误,为什么报这错啊?在别的页面用的时候没错啊
求解啊