我做的一个博客系统,首页点击文章标题跳转进文章详细内容页里: <p><a href='article.aspx?wenzhang=<%# Eval("id") %>'> <%# Eval("biaoti") %> </a></p>但是详细内容页里如何从数据里读出当前文章的详细信息来,比如标题 、发表时间、作者、内容等,SQL语句如何写读出满足条件的语句?<asp:Repeater ID="Repeater1" runat="server">
                        <ItemTemplate>
                           <div id="titleA">
                                <h1>
                               <asp:Label ID="Label7" runat="server" Text='<%# Eval("biaoti") %>'></asp:Label></h1> 
                               <asp:Label ID="Label3" runat="server" Text="发表时间:" Font-Size="12px"  ForeColor="#000"></asp:Label>
                               <asp:Label ID="Label1" runat="server" Text='<%#  Convert.ToDateTime(Eval("fabiaoshijian")).ToString("MM月dd日H:mm") %>' Font-Size="12px" ForeColor="#000"></asp:Label>
                               <asp:Label ID="Label2" runat="server" Text='<%# Eval("laiyuan") %>' Font-Size="12px" ForeColor="#000"></asp:Label>
                               <asp:Label ID="Label4" runat="server" Text="浏览 " Font-Size="12px"  ForeColor="#000"></asp:Label><span class="dianji"><%# Eval("dianji") %></span>
                               <asp:Label ID="Label5" runat="server" Text="次"  Font-Size="12px"  ForeColor="#000"></asp:Label>
                           </div>
                           <div id="neirongB">
                                <span class="neirongA"><%# Eval("neirong") %></span>
                                <p>如果你喜欢本文,欢迎常来本站看看以获得本站最新内容。</p>
                           </div>
                        </ItemTemplate>
                    </asp:Repeater>
            string sql1 = "select * from news";
            Repeater1.DataSource = Clas.Class2.chaxun(sql1);
            Repeater1.DataBind();

解决方案 »

  1.   

    select * from news where id="你点击标题传过来的编号".
      

  2.   

    在详细页还用repeater干么?直接在aspx页面放几个Label或Literal,在cs页面通过select * from 表 where id=Request.QueryString["id"]然后得到一个DataTable dt,然后直接给aspx页面的Label赋值像这样this.Latel1.Text=dt.Rows[0]["文章标题"].ToString()就可以了
      

  3.   

     跳转时这样写:<p><a href='article.aspx?id=<%# Eval("id") %>'>&biaoti=<%# Eval("biaoti") %> </a></p>cs文件中 获取id  string id=Request.querystring["id"]select * from news where id=id    "你点击标题传过来的编号".
      

  4.   


    详细页用repeater还是有很多好处的,至少可以绑定,不需要一个个赋值
      

  5.   

    Request.QueryString["wenzhang"]取值
    select * from tb where id=@id 查询数据
    Literal显示数据
    formview
      

  6.   

    lable或者Literal显示数据,
    后台代码可以类似如此:sql = "select * from news where id="+RequestQueryString["id"];
    DataTable myTable = Clas.Class2.chaxun(sql1);
    //取值:
    if (myTable != null)
    {
    label1.Text = myTable.Rows[0]["biaoti"].ToString();
    }
      

  7.   

    用个数据源控件就可以不用写后台代码,代码写的越少越好维护,建议还是用repeater吧,别写后台代码一个个赋值给lable或者Literal了