日期:2014-05-18 浏览次数:20443 次
<asp:Repeater ID="RepeaterTuijian" runat="server"> <ItemTemplate> <div id="b21"> <div id="b22"><img src="images2/images/<%# Eval("photo") %>" alt="<%# Eval("bookname") %>" width="60" /></div> <p class="b23"><%# Eval("bookname") %></p> <p class="b24">作者:<%# Eval("author") %> </p> <p class="b24">出版社:<%# Eval("publisher") %></p> <p class="b24">出版时间:<%# Eval("cbshijian") %></p> <p class="b24">定价:¥<%# Eval("price") %> 当当价:¥<%# Eval("xiaoshoujia") %> </p> <p class="b25"><%# JieQu(Eval("tuijian"),30) %></p> </div> </ItemTemplate> </asp:Repeater>
protected void Page_Load(object sender, EventArgs e) { string connStr = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + Server.MapPath("mdb\\jiuzhou.mdb"); OleDbConnection conn = new OleDbConnection(connStr); OleDbCommand cmd = new OleDbCommand("SELECT TOP 2 * FROM book WHERE (((lanmu)='主编推荐')) ORDER BY bookID DESC", conn); conn.Open(); OleDbDataReader dr = cmd.ExecuteReader(); RepeaterTuijian.DataSource = dr; RepeaterTuijian.DataBind(); conn.Close(); } public string JieQu(string inputString, string Len) { int tempLen = 0; string tempString = ""; int len = Convert.ToInt32(Len); if (inputString.Length > len) { tempString = inputString.Substring(0, len)+"…";//截获前len个字符并加上… } else { tempString = inputString; } return tempString;