日期:2014-05-18 浏览次数:20424 次
NewsDao.cs #region 根据新闻类别Id取出该类别下的所有新闻 public DataTable SelectByCaId(int caid) { DataTable dt = new DataTable(); string cmdText = "news_SelectBycaId"; SqlParameter[] paras = new SqlParameter[] { new SqlParameter("@caid",caid) }; dt = sqlhelp.ExecuteQuery(cmdText, paras, CommandType.StoredProcedure); return dt; } #endregion NewsManager.cs #region 根据新闻类别Id取出该类别下的所有新闻 public DataTable SelectByCaId(int caid) { return newsDao.SelectByCaId(caid); } #endregion List.aspx.cs if (!Page.IsPostBack) { string caid= Request.QueryString["caid"]; //绑定新闻列表 gvNews.DataSource = new NewsManager().SelectByCaId(caid); gvNews.DataBind(); }
set ANSI_NULLS ON set QUOTED_IDENTIFIER ON go ALTER PROCEDURE [dbo].[news_SelectBycaId] @caid int AS BEGIN select n.id,n.title,n.createTime,c.caName , n.caId from _news n inner join _category c on n.caId=c.id and n.caId=@caid order by n.createTime desc END