【问题标题】:i m getting Error in in Repeater with in Repeater in Data Source我在数据源中的中继器中出现错误
【发布时间】:2014-11-16 02:42:57
【问题描述】:

    <b><%# DataBinder.Eval(Container.DataItem, "Hotel_FloorId")%></b> 
     <b><%# DataBinder.Eval(Container.DataItem, "Hotel_FloorName")%></b>    


     <br>
    <asp:repeater id="childRepeater" runat="server" datasource='<%# ((DataRowView)Container.DataItem).Row.GetChildRows ("myrelation") %>' >
        <itemtemplate>
            <%# DataBinder.Eval(Container.DataItem, "[\"RoomDoorNo\"]")%><br>   
        </itemtemplate>
    </asp:Repeater> 

  </itemtemplate>

protected void Page_Load(object sender, EventArgs e)
{

    string css = ConfigurationManager.ConnectionStrings["CS"].ConnectionString;
    SqlConnection cnn = new SqlConnection(css);
    cnn.Open();
    SqlDataAdapter cmd1 = new SqlDataAdapter("SELECT *  FROM   HM_Hotel_Floor", cnn);
    DataSet ds = new DataSet();
    cmd1.Fill(ds, "Floors");
    parentRepeater.DataSource = ds.Tables["Floors"];



    SqlDataAdapter cmd2 = new SqlDataAdapter("select * from HM_Rooms", cnn);
    cmd2.Fill(ds, "Rooms");
    ds.Relations.Add("myrelation", ds.Tables["Floors"].Columns["Hotel_FloorId"], ds.Tables["Rooms"].Columns["Hotel_FloorId"]);
    Page.DataBind();



}

错误是编译器错误消息:CS0246:找不到类型或命名空间名称“DataRowView”(您是否缺少 using 指令或程序集引用?)

请任何人帮助我

【问题讨论】:

  • 添加这个命名空间Using System.Data;

标签: c# asp.net datasource


【解决方案1】:

代码隐藏 (.cs) 和页面 (.aspx) 文件有自己的类,因此它们也有单独的导入。在这种情况下,您缺少 ASPX 视图顶部的导入:

<%@ Import Namespace="System.Data" %>

这是必需的,因为您要将 Container.DataItem 投射到 ASPX 视图中的 DataRowView。

此外,请确保您的代码隐藏文件中也有 using 语句:

Using System.Data;

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-06-27
    • 2022-07-05
    • 1970-01-01
    • 2020-06-29
    相关资源
    最近更新 更多