页面代码
<health:Repeater ID="rpUserList" runat="server" OnItemDataBound="rpUserList_ItemDataBound">
                        <ItemTemplate>
                            <tr class="tr_bg_odd">
                                <td class="listbor01">
                                    <%# Convert.ToString(Container.ItemIndex + 1) %>
                                </td>
                                <td class="listbor03">                       
                                    <%#Eval("UesrName") %>
                                </td>
                                <td class="listbor03">
                                    <%#Eval("RealName") %>
                                </td>
                            </tr>
                        </ItemTemplate>
                    </health:Repeater>
后代代码 
private void UserList(int userId)
    {
        
        string connectionString = ConfigurationManager.ConnectionStrings["db_health"].ConnectionString;
        SqlConnection conn = new SqlConnection(connectionString);
        conn.Open();
        string sql =string.Format( "select * from health_user where user_id in(select user_id from health_user_doctor where doctor_id='{0}')",userId);
        SqlDataAdapter adapter = new SqlDataAdapter(sql,conn);
        DataTable ds = new DataTable();
        adapter.Fill(ds);
       // if (ds.Tables[0].Rows.Count != 0)
       // { 
             rpUserList.DataSource = ds;
             rpUserList.DataBind();
        //}  
    }
页面代码提示:DataBinding:“System.Data.DataRowView”不包含名为“UesrName”的属性。
数据库能够查出数据,后台代码只有这一个方法,不知道能不能实现前台绑定查出数据。

解决方案 »

  1.   

    不包含名为“UesrName”的属性
      

  2.   

    你也可以直接在前台循环数据.
     <%
                    if (ViewData["RecordeCount"].ToString() != "0")
                    {
                        foreach (var item in Model)
                        { %>
                <tr>
                    <td align="center" style="line-height: 150%">
                        <%=Html.Encode(item.LocalDate )%>
                    </td>
    <% } %>
                <%}
                    else
                    {%>后台将实体类集合保存到ViewData中
    List<Model_CDRMAIN> ListModelCDRMAIN = new List<Model_CDRMAIN>();
    ViewData["RecordeCount"]=ListModelCDRMAIN ;
      

  3.   

    数据库表里有“UesrName”这个字段没
      

  4.   

    "UesrName" 数据库的字段和你前台绑定的字段不一样
      

  5.   

    是查询出来的时候缺少UserName字段
      

  6.   

    我觉得可能是你拼写错误
    例如:UserName
    或者你的数据库里字段是UesrsName
      

  7.   

    DataTable 数据集中  是否包含DataTable??
     前台绑定 查询
      列 <%=查询方法%>
      

  8.   

    <%#Eval("UesrName") %>
    红色部分写错了
    UserName写成UesrName,当然报错了
      

  9.   

    http://www.w3school.com.cn/aspnet/aspnet_repeater.asp
      

  10.   

     <%#Eval("UesrName") %>认真点,写错了
      

  11.   

    <%#Eval("UesrName") %>
    写反了