日期:2014-05-17 浏览次数:20449 次
<ul> <asp:Repeater ID="Repeater2" runat="server"> <ItemTemplate> <li> <span class="s1"><a href='DetailInf.aspx?NewsId=<%# Eval("NewsId") %>'> <%#GetSrCount(Eval("Title").ToString())%> </a></span> <span class="s2"> <%# Eval("EditDate","{0:yyyy-MM-dd}")%> </span> </li> </ItemTemplate> </asp:Repeater> </ul>
Repeater11.DataSource = CMSNews.showShouYe(55); //调用类中的方法 Repeater11.DataBind(); 类中的方法: public DataTable showShouYe(int str_classid) { DataSet ds = new DataSet(); string str_showsql = "select top 6 * from CMS_News where DeleteFlag = '0' and ClassId= " + str_classid + " order by EditDate desc"; Database db = DatabaseFactory.CreateDatabase("diaonianyuConnectionString"); DbCommand cmd = db.GetSqlStringCommand(str_showsql); try { ds = db.ExecuteDataSet(cmd); } catch (Exception ex) { WebHelper.Alert("CMS_News.cs Error!"); } return ds.Tables[0]; // 返回 arraylist }