1

看起来这应该是一件容易的事。我有一架 Ajax 手风琴。每个窗格都有一个标题,基本上是该窗格的“标题”。我正在使用这个手风琴来显示和隐藏博客中的评论。因此,标题是“评论”,但我想用评论的数量来修改它,所以它说“评论(23)或类似的东西。我的 SQL 将计数返回为“评论计数”,所以我应该能够修改这个:

            <Panes>
            <AjaxToolkit:AccordionPane runat="server" ID="OverviewPane">
                <Header>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Comments</Header>

...对此:

            <Panes>
            <AjaxToolkit:AccordionPane runat="server" ID="OverviewPane">
                <Header>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Comments (<%# Eval("CommentCount")%>)</Header>

...并且没关系,但它不起作用。我在每篇博文上都会收到“评论 ()”。

也许问题出在代码隐藏中?

        Utility myUtility = new Utility();
        SqlConnection myConn = myUtility.GetConnection();
        string myCommandText = "select [KeyID],[ShadeDate],[ShadeTitle],[ShadeBody],[ShadeImage],count([Comments].[CommentID]) as CommentCount from [Shades] left join [Comments] on [Shades].[KeyID] = [Comments].[ShadeID] group by [KeyID],[ShadeTitle],[ShadeImage],[ShadeBody],[ShadeDate] order by ShadeDate DESC";
        SqlCommand myCommand = new SqlCommand(myCommandText, myConn);
        SqlDataAdapter myDataAdapter = new SqlDataAdapter(myCommand);
        DataSet myDataSet = new DataSet();

        try
        {
            myDataAdapter.Fill(myDataSet);
            DataTable myDataTable = myDataSet.Tables[0];
            ShadesRepeater.DataSource = myDataTable;
            ShadesRepeater.DataBind();
        }
4

0 回答 0