日期:2014-05-17 浏览次数:20430 次
<asp:DataList ID="listC" runat="server"> <ItemTemplate> <asp:Label ID="listTitle" runat="server" Text='<%# Eval("news_title") %>' /> </ItemTemplate> </asp:DataList>
protected void Page_Load(object sender, EventArgs e) { string sql = "select top 15 from News where catagory_id=" + Request.QueryString["catagory_id"] + ""; SqlConnection cn = new SqlConnection(ConfigurationManager.ConnectionStrings["new_conn"].ConnectionString); cn.Open(); SqlCommand cmd = new SqlCommand(sql, cn); SqlDataReader dr = cmd.ExecuteReader(); if (dr.Read()) { listTitle.Text = dr["news_title"].ToString(); } }
<asp:DataList ID="listC" runat="server"> <ItemTemplate> <asp:Label ID="listTitle" runat="server" Text='<%# Eval("news_title") %>'></asp:Label> </ItemTemplate> </asp:DataList>