Asp.Net Repeater控件嵌套查询

    我想实现的功能是现实一频道下的所有栏目下的前8篇文章。
html代码如下:
<asp:Repeater ID="repChannel" runat="server" >
                <HeaderTemplate>
   <div class="leftList">
                </HeaderTemplate>
                <ItemTemplate>
                                <asp:Repeater ID="repCategory" runat="server" DataSource='<%# GetCategoryArticle(Eval("ID").ToString()) %>'>
                <HeaderTemplate>
                <div class="blank20"></div>
                <ul>
                </HeaderTemplate>
                <ItemTemplate>
                <li>
           <h5>[<a href='ShowCategory.aspx?CategoryID=<%# DataBinder.Eval(Container.DataItem, "CategoryID")%>'><%# DataBinder.Eval(Container.DataItem, "CategoryID")%></a>] <a href='ShowArticle.aspx?CategoryID=<%# DataBinder.Eval(Container.DataItem, "CategoryID")%>&ArticleID=<%# DataBinder.Eval(Container.DataItem, "Article.ID")%>'><%# DataBinder.Eval(Container.DataItem, "Article.Title")%></a></h5>
           <h6><%# DataBinder.Eval(Container.DataItem, "PubDate")%></h6>
          </li>
                </ItemTemplate>
                <FooterTemplate></ul></FooterTemplate>
                </asp:Repeater>
                </ItemTemplate>
                <FooterTemplate>
                </div>
                </FooterTemplate>
                </asp:Repeater>
cs代码如下:
    protected OleDbDataReader GetCategoryArticle(string cid)
    {
        string StrConn = ConfigurationManager.ConnectionStrings["jcbConnectionString"].ConnectionString;
        string strSql = "select top 8 * from CCListView where CategoryID=" + cid + " order by Article.ID desc";
        OleDbConnection objConn = new OleDbConnection(StrConn);
        OleDbCommand objCmd = new OleDbCommand(strSql, objConn);
        objConn.Open();
        return objCmd.ExecuteReader(CommandBehavior.CloseConnection);
    }

CCListView视图如下:

执行结果:
DataBinding:“System.Data.Common.DbDataRecord”不包含名为“Article”的属性。

难道不可以这样吗??

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值