首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > asp.net >

新闻的内容页有关问题(人人都有分)

2012-04-09 
新闻的内容页问题(人人都有分)新闻列表页我用GirdView 控件显示新闻列表:NewsList.aspxID传值到ShowNews.a

新闻的内容页问题(人人都有分)
新闻列表页我用GirdView 控件显示新闻列表:NewsList.aspx
ID传值到ShowNews.apx页面

ShowNews.apx 我用什么方法(或者控件)显示新闻的标题、发布时间、新闻内容呢
有代码实例说明最佳

[解决办法]
页面后台代码
 public DataEntity.Article article;

public int ArticleID
{
get
{
if (ViewState["ArticleID"] != null && TypeParse.IsNumeric(ViewState["ArticleID"]))
return Convert.ToInt32(ViewState["ArticleID"]);
else
return 0;
}
set
{
ViewState["ArticleID"] = value;
}
}

protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
if (Request.QueryString["ArticleID"] != null && TypeParse.IsNumeric(Request.QueryString["ArticleID"]))
{
ArticleID = Convert.ToInt32(Request.QueryString["ArticleID"]);
}
}
BindData();
}


private void BindData()
{
ArticleManager am = new ArticleManager();
article = am.GetModel(ArticleID); 
}


aspx页面
<table class="artictable">
<tr>
<th class="blanklink">
<%=article.Title%>
</th>
<td class="datetd">
<%=article.CreateDate.Value.ToString("yyyy-MM-dd")%>
</td>
</tr>
<tr>
<td colspan="2">
<%=article.Content%>
</td>
</tr>
</table>
[解决办法]

探讨
页面后台代码
public DataEntity.Article article;

public int ArticleID
{
get
{
if (ViewState["ArticleID"] != null && TypeParse.IsNumeric(ViewState["ArticleID"]))
return Convert.ToInt32(ViewState["ArticleID"]);
else
return 0;
}
set


[解决办法]
用空间么用label就可以了

分页可以用标记来分页 ,因为难免新闻会有图片,如果程序自动分页的话会不合理的
[解决办法]

[解决办法]
用Label显示就可以了啊。
[解决办法]
支持用LABEL
[解决办法]
lz是相当的业余阿,搞得这样的问题提问,是不是算送分阿?
你可以使用<a>来显示,也可以使用label或者任何可以显示的控件
[解决办法]
呵,飘过~~~
探讨
用Label显示就可以了啊。

[解决办法]
jf
[解决办法]
lable
有runat=server的span div等都可以

呵呵 jf
[解决办法]
呵呵。JF
------解决方案--------------------


用repeater也可以撒
[解决办法]
repeater 好像不合适,不好意思,看错了

那就用<table>
或者服务器端的<table>



[解决办法]
给你写段代码
你可以用三个Label显示
后台代码这样写

C# code
private void Page_Load(object sender, System.EventArgs e)        {            // 在此处放置用户代码以初始化页面            if (!IsPostBack)            {                string strId = Request.QueryString["id"].ToString();                string strSql = "select * from TS_SERVER_MGR where SM_id='" +strId+ "'";                BaseService bc = new BaseService();                DataTable dt = bc.ExecuteDataTable(strSql);                foreach (DataRow dr in dt.Rows)                {                    lbl3.Text = dr["标题"].ToString();                    lbl2.Text = dr["时间"].ToString();                    lbl1.Text = dr["内容"].ToString();                }            }        }
[解决办法]
用表达式显示就可以了啊

 <table
<tr> 
<td>
<%=article.Title%> 
<td>
</tr> 
<tr> 
<td>
<%=article.Content%> 
</td> 
</tr> 
</table>
[解决办法]
后台
C# code
public partial class ArticleShow : System.Web.UI.Page{    public string ArticleTitle = "";    public string ArticleContent = "";    protected void Page_Load(object sender, EventArgs e)    {        //if (!Page.IsPostBack)         //{            if ((Request.Params["id"] != null) && (Request.Params["id"].ToString() != ""))            {                string id = Request.Params["id"];                ShowArticle(int.Parse(id));            }        //}   }    private void ShowArticle(int ArticleID)//显示新闻    {        model = bll.GetModel(ArticleID);        ArticleTitle = model.ArticleTitle;        ArticleContent = model.ArticleContent;    }}
[解决办法]
lz在送分?
用formview(专为绑定一条数据的)
前台: 
<asp:FormView ID="FormView1" runat="server" Width="100%">
<ItemTemplate>
<table align="center" bgcolor="#ffffff" border="1" bordercolordark="#efefef" bordercolorlight="#83bbd9"
cellspacing="0" class="bian" width="95%">
<tr>
<td bgcolor="#ffffff" class="contact1" height="26" width="26%">
&nbsp;新闻标题 <%#Eval("news_title")%></td>
<td bgcolor="#ffffff" class="contact1" width="24%">
&nbsp;新闻内容:<%#Eval("news_content")%></td>
<td bgcolor="#ffffff" class="contact1" style="width: 284px">
&nbsp;
&nbsp;作者:<%#Eval("news_author")%></td><td class="contact1">
&nbsp;时间<%#Eval("news_time")%></td>
</tr>
</table>
</ItemTemplate>
后台:
直接绑定(就不用写了吧)1楼很详细
  
楼主要加强学习了


------解决方案--------------------


探讨
用Label显示就可以了啊。

[解决办法]
我一般用litera ,这个才是原本的按你自己的输出内容输出的,
LABEL的客户端的表现是个<SPAN>
[解决办法]
方法很多,首先传递参数后可用DataRowView实现从数据库中检索
至于要用什么显示的话,图方便就用Label吧
记得加分哦
[解决办法]
呵呵,接分
[解决办法]
帶值給label就可以了。
[解决办法]
jf
[解决办法]
帮顶&&接分
[解决办法]
UP
[解决办法]

 用 Literal

 用法跟 Label 一样。但比 Lable 还要简单。生成的客户端代码也少。
[解决办法]

 用 Literal

 用法跟 Label 一样。但比 Lable 还要简单。生成的客户端代码也少。
[解决办法]
帮顶,我们是用Table+Label显示的
[解决办法]
友情UP...
[解决办法]
up
[解决办法]

[解决办法]
C# code
 /// <summary>    /// 根据ID号批量删除信息    /// </summary>    /// <param name="id">商品编号</param>    /// <returns></returns>    public static bool DeleteNews(int id)    {        bool Flage = false;        string procname = "dbo.DeleteNews";        SqlParameter[] prams ={ new SqlParameter("@NewsID", SqlDbType.Int) };        prams[0].Value = id;        int intResult = SQlData.RunExecute(procname, prams);        if (intResult > 0)        {            Flage = true;        }        return Flage;    }    public static List<News> GetAllNews()    {        List<News> AllNews = new List<News>();        string procname = "dbo.GetNewsInfo";        SqlDataReader Dr = SQlData.RunProcGetReader(procname);        while (Dr.Read())        {            AllNews.Add(new News(Dr));        }        Dr.Close();        return AllNews;    }     /// <summary>    /// 验证新闻标题    /// </summary>    /// <param name="NewsTitle"></param>    /// <returns></returns>    public static bool IsValidateNewsTitle(string NewsTitle)    {        bool Flage = false;        string procname = "dbo.IsValidateNewsTitle";        SqlParameter[] prams ={ new SqlParameter("@NewsTitle", SqlDbType.VarChar, 200) };        prams[0].Value = NewsTitle;        int intResult = SQlData.RunExecuteScalar(procname, prams);        if (intResult > 0)        {            Flage = true;        }        return Flage;    }    /// <summary>    /// 得到最新新闻    /// </summary>    /// <param name="NewsKindId"></param>    /// <param name="IntTop"></param>    /// <returns></returns>    public static List<News> GetTopNews(int NewsParentId, int IntTop)    {        List<News> AllNews = new List<News>();        string procname = "dbo.GetTopNews";        SqlParameter[] prams ={ new SqlParameter("@ParentId", SqlDbType.Int),                                new SqlParameter("@IntTop", SqlDbType.Int)};        prams[0].Value = NewsParentId;        prams[1].Value = IntTop;        SqlDataReader Dr = SQlData.RunProcGetReader(procname, prams);        while (Dr.Read())        {            AllNews.Add(new News(Dr));        }        Dr.Close();        return AllNews;    }    /// <summary>    /// 更新新闻内容    /// </summary>    /// <param name="SingleNews"></param>    /// <returns></returns>    public static bool UpdateNews(News SingleNews)    {        bool Flage = false;        string procname = "dbo.UpdateNews";        SqlParameter[] prams ={                                new SqlParameter("@NewsID",SqlDbType.Int),                               new SqlParameter("@NewsTitle",SqlDbType.VarChar),                               new SqlParameter("@NewsContent",SqlDbType.NText),                               new SqlParameter("@ParentID",SqlDbType.Int),                               new SqlParameter("@NewsKeyword",SqlDbType.VarChar),                               new SqlParameter("@NewsPicture",SqlDbType.VarChar),                               new SqlParameter("@NewsFrom",SqlDbType.VarChar),                               new SqlParameter("@Author",SqlDbType.VarChar),                               new SqlParameter("@NewsDescription",SqlDbType.VarChar)                                   };        prams[0].Value = SingleNews.NewsID;        prams[1].Value = SingleNews.NewsTitle;        prams[2].Value = SingleNews.NewsContent;        prams[3].Value = SingleNews.ParentID;        prams[4].Value = SingleNews.NewsKeyword;        prams[5].Value = SingleNews.NewsPic;        prams[6].Value = SingleNews.NewsFrom;        prams[7].Value = SingleNews.Author;        prams[8].Value = SingleNews.NewsDescription;        int intResult = SQlData.RunExecute(procname, prams);        if (intResult > 0)        {            Flage = true;        }        return Flage;    }    /// <summary>    /// 分页    /// </summary>    /// <param name="PageSize">每页的数量</param>    /// <param name="CurrentPage">当前页</param>    /// <param name="strWhere">条件</param>    /// <param name="Record">记录数</param>    /// <returns></returns>    //public static DataTable GetAllNewsByStrWhere(int PageSize, int CurrentPage, string strWhere, out int Record)    //{    //    DataTable Dt = new DataTable();    //    SqlParameter[] prams ={    //                        new SqlParameter("@TableNames",SqlDbType.VarChar,300),//表名,可以是多个表,但不能用别名    //                           new SqlParameter("@PrimaryKey",SqlDbType.VarChar,100),//主键,可以为空,但@Order为空时该值不能为空    //                           new SqlParameter("@Fields",SqlDbType.VarChar,350),//要取出的字段,可以是多个表的字段,可以为空,为空表示select *    //                           new SqlParameter("@PageSize",SqlDbType.Int),//每页记录数    //                           new SqlParameter("@CurrentPage",SqlDbType.Int),//当前页,0表示第1页    //                           new SqlParameter("@Filter",SqlDbType.VarChar,200),//条件,可以为空,不用填 where    //                           new SqlParameter("@Group",SqlDbType.VarChar,200),//分组依据,可以为空,不用填 group by    //                           new SqlParameter("@Order",SqlDbType.VarChar,200),//排序,可以为空,为空默认按主键升序排列,不用填 order by    //                           new SqlParameter("@RecordCount",SqlDbType.Int) };    //    prams[0].Value = "NewsInfo left join NewsCategory on News.ParentID=NewsCategory.NewsID";    //    prams[1].Value = "NewsInfo.NewsID";    //    prams[2].Value = "NewsInfo.NewsID,NewsInfo.NewsTitle,News.CreateTime,NewsCategory.Newstitle";    //    prams[3].Value = PageSize;    //    prams[4].Value = CurrentPage - 1;    //    prams[5].Value = strWhere;    //    prams[6].Value = string.Empty;    //    prams[7].Value = "NewsInfo.CreateTime Desc";    //    prams[8].Direction = ParameterDirection.Output;    //    SqlConnection Conn = SQlData.ReturnConn();    //    Dt = DataBase.RunProcGetTable("usp_PagingLarge", prams, Conn);    //    Record = Convert.ToInt32(prams[8].Value);    //    Conn.Close();    //    return Dt;    //}    /// <summary>    /// 根据新闻ID得到新闻内容    /// </summary>    /// <param name="NewsId">新闻ID</param>    /// <returns></returns>    public static SqlDataReader GetDrNewByNewsId(int NewsId)    {        string procname = "dbo.GetDrNewByNewsId";        SqlParameter[] prams ={ new SqlParameter("@NewsId", SqlDbType.Int) };        prams[0].Value = NewsId;        SqlDataReader Dr = SQlData.RunProcGetReader(procname, prams);        return Dr;    }    /// <summary>    /// 根据新闻ID得到该条新闻的信息    /// </summary>    /// <returns></returns>    public static DataTable GetNewsInfo(int newsid)    {        string procname = "dbo.GetNewsInfoByid";        SqlParameter[] prams ={ new SqlParameter ("@NewsID",SqlDbType.Int) };        prams[0].Value = newsid;        DataTable dt = SQlData.RunProcGetTable(procname,prams);        return dt;    } 


[解决办法]

C# code
 /// <summary>    /// 前台的详细信息显示    /// </summary>    /// <param name="NewsID"></param>    /// <returns></returns>    public static SqlDataReader GetNewsInfoByNewsID(int NewsID)    {        string procname = "dbo.GetNewsInfoByNewsID";        SqlParameter[] prams ={ new SqlParameter("@NewsID", SqlDbType.Int) };        prams[0].Value = NewsID;        SqlDataReader Dr = SQlData.RunProcGetReader(procname, prams);        return Dr;    }    /// <summary>    /// 得到所有的新闻信息(分页)    /// </summary>    /// <returns></returns>    public static DataSet GetAllNewsInfo()    {        string procname = "dbo.GetNewsInfo";        DataSet ds = SQlData.RunProcGetAll(procname);        return ds;    }    /// <summary>    /// 得到所有的新闻信息(分页table)    /// </summary>    /// <returns></returns>    public static DataTable  GetNewsInfo()    {        string procname = "dbo.GetNewsInfo";        DataTable dt = SQlData.RunProcGetTable(procname);        return dt;    }    /// <summary>    /// 根据新闻类别id得到该类新闻信息    /// </summary>    /// <param name="newstypeid"></param>    /// <returns></returns>    public static DataSet GetAllNewsListByType(int newstypeid)    {        string proname = "GetAllNewsListByType";        SqlParameter[] prams ={                                new SqlParameter("@NewsTypeID",SqlDbType.Int)                              };        prams[0].Value = newstypeid;        DataSet ds = SQlData.RunProcGetAll(proname, prams);        return ds;    }    /// <summary>    /// 得到ParentID为2的所有新闻的信息    /// </summary>    /// <returns></returns>    public static DataTable GetNewsList2()    {        string proname = "dbo.GetNewsList2";        DataTable dt = SQlData.RunProcGetTable(proname);        return dt;    }    /// <summary>    /// 得到ParentID为1的所有新闻的信息    /// </summary>    /// <returns></returns>    public static DataTable GetNewsList1()    {        string proname = "GetNewsList1";        DataTable dt = SQlData.RunProcGetTable(proname);        return dt;    }    /// <summary>    /// 得到产品新闻信息    /// </summary>    /// <returns></returns>    public static DataSet GetProductNewsList()    {        string proname = "dbo.GetProductNewsList";        DataSet ds = SQlData.RunProcGetAll(proname);        return ds;    }      /// <summary>    /// 得到其它新闻信息    /// </summary>    /// <returns></returns>    public static DataSet GetOtherNewsList()    {        string proname = "dbo.GetOtherNewsList";        DataSet ds = SQlData.RunProcGetAll(proname);        return ds;    }    public static DataTable GetAllAdvertiseMent(int ParentID)    {        string proname = "GetAllAdvertiseMent";        SqlParameter[] prams ={ new SqlParameter("@ParentID", SqlDbType.Int) };        prams[0].Value = ParentID;        DataTable dt = SQlData.RunProcGetTable(proname, prams);        return dt;    }   }
[解决办法]
C# code
using System;using System.Data;using System.Configuration;using System.Web;using System.Web.Security;using System.Web.UI;using System.Web.UI.WebControls;using System.Web.UI.WebControls.WebParts;using System.Web.UI.HtmlControls;using System.Data.SqlClient;using System.Collections.Generic; /// <summary>/// NewsCategory 的摘要说明/// </summary>public class NewsCategory{    public NewsCategory()    {        //        // TODO: 在此处添加构造函数逻辑        //    }    /// <summary>    /// 新闻类别ID    /// </summary>    private int _newstypeid;    public int NewsTypeID    {        get { return this._newstypeid; }        set { this._newstypeid = value; }    }    /// <summary>    /// 新闻类别名    /// </summary>    private string _newstitle;    public string NewsTitle    {        get { return this._newstitle; }        set { this._newstitle = value; }    }    /// <summary>    /// 新闻描述    /// </summary>    //private string _newsdesciption;    //public string NewsDesciption    //{    //    get { return this._newsdesciption; }    //    set { _newsdesciption = value; }    //}    public NewsCategory(SqlDataReader Dr)    {        this._newstypeid = Convert.ToInt32(Dr["NewsTypeID"]);        this._newstitle = Convert.ToString(Dr["NewsTitle"]);    }    //public NewsCategory(int UserId, string UserName)    //{    //    this._newstypeid =KindId;    //    this._newstitle=KindName;    //}    public NewsCategory(int Newstypeid, string Newstitle)    {        this._newstypeid = Newstypeid;        this._newstitle = Newstitle;    }    /// <summary>    /// 得到所有的新闻类型    /// </summary>    /// <returns></returns>    public static List<NewsCategory> GetAllNewsCategory()    {        List<NewsCategory> AllNewsKinds = new List<NewsCategory>();        string procname = "dbo.GetAllNewsCategory";        SqlDataReader Dr = SQlData.RunProcGetReader(procname);        while (Dr.Read())        {            AllNewsKinds.Add(new NewsCategory(Dr));        }        Dr.Close();        return AllNewsKinds;    }    /// <summary>    /// 根据新闻类型ID获得新闻类型名    /// </summary>    /// <param name="KindId"></param>    /// <returns></returns>    public string GetKindNameByKindId(int NewsTypeID)    {        string strKindName = string.Empty;        string procname = "dbo.GetCategoryNameById";        SqlParameter[] prams ={ new SqlParameter("@NewsTypeID", SqlDbType.Int) };        prams[0].Value = NewsTypeID;        SqlDataReader Dr = SQlData.RunProcGetReader(procname);        while (Dr.Read())        {            strKindName = Dr["NewsTitle"].ToString();        }        Dr.Close();        return strKindName;    }   /// <summary>   /// 添加新闻类别   /// </summary>   /// <param name="CategoryInfo"></param>   /// <returns></returns>    public static bool AddNewsCategory(NewsCategory CategoryInfo)    {        bool Flage = false;        string procname = "dbo.AddNewsCategory";        SqlParameter[] prams ={                                new SqlParameter("@NewsTitle",SqlDbType.VarChar)        };        prams[0].Value = CategoryInfo.NewsTitle;        int intResult = SQlData.RunExecute(procname, prams);        if (intResult > 0)        {            Flage = true;        }        return Flage;    }    /// <summary>    /// 删除新闻类别名    /// </summary>    /// <param name="CategoryInfo"></param>    /// <returns></returns>    public static bool DeleteNewsCategory(NewsCategory CategoryInfo)    {        bool Flage = false;        string procname = "dbo.DeleteCategoryNews";        SqlParameter[] prams ={ new SqlParameter("@NewsTypeID", SqlDbType.Int) };        prams[0].Value = CategoryInfo.NewsTypeID;        int intResult = SQlData.RunExecute(procname, prams);        if (intResult > 0)        {            Flage = true;        }        return Flage;    }    /// <summary>    /// 更新新闻类别名    /// </summary>    /// <param name="CategoryInfo"></param>    /// <returns></returns>    public static bool UpdateNewsCategory(NewsCategory CategoryInfo)    {        bool Flage = false;        string procname = "dbo.UpdateCategoryNews";        SqlParameter[] prams ={                              new SqlParameter("@NewsTypeID",SqlDbType.Int),                               new SqlParameter("@NewsTitle",SqlDbType.VarChar)                                                                };        prams[0].Value = CategoryInfo.NewsTypeID;        prams[1].Value = CategoryInfo.NewsTitle;              int intResult = SQlData.RunExecute(procname, prams);        if (intResult > 0)        {            Flage = true;        }        return Flage;    }    /// <summary>    /// 首页显示新闻类别    /// </summary>    /// <returns></returns>    public static SqlDataReader GetTopNewsCategory()    {        string procname = "dbo.GetTopNewsCategory";        SqlDataReader dr = SQlData.RunProcGetReader(procname);        return dr;    }    /// <summary>    /// 前台的详细信息显示    /// </summary>    /// <param name="NewsID"></param>    /// <returns></returns>    public static SqlDataReader GetNewsInfoByNewsID(int NewsID)    {        string procname = "dbo.GetNewsInfoByNewsID";        SqlParameter[] prams ={ new SqlParameter("@NewsID", SqlDbType.Int) };        prams[0].Value = NewsID;        SqlDataReader Dr = SQlData.RunProcGetReader(procname, prams);        return Dr;    }    /// <summary>    /// 返回所有的新闻类别信息(分页)    /// </summary>    /// <returns></returns>    public static DataTable GetNewsCategory()    {        string proname = "GetAllNewsCategory";        DataTable dt = SQlData.RunProcGetTable(proname);        return dt;    }   } 


[解决办法]

C# code
using System;using System.Data;using System.Configuration;using System.Collections;using System.Web;using System.Web.Security;using System.Web.UI;using System.Web.UI.WebControls;using System.Web.UI.WebControls.WebParts;using System.Web.UI.HtmlControls;public partial class Controls_INewsAllList : System.Web.UI.UserControl{    PagedDataSource pds = new PagedDataSource();    DataSet ds;    protected void Page_Load(object sender, EventArgs e)    {        if (!Page.IsPostBack)        {            bind_load();            if (this.dlProduct.Items.Count <= 0)            {                this.lblCurrentPage.Text = "无产品";                this.btnGO.Enabled = false;                this.lbtnOne.Enabled = false;                this.lbtnPre.Enabled = false;                this.lbtnLast.Enabled = false;                this.lbtnNext.Enabled = false;            }            this.lbtnOne.Enabled = false;            this.lbtnPre.Enabled = false;        }    }    private void bind_load()    {        ds = News.GetAllNewsInfo();        dlProduct.DataSource = ds;        dlProduct.DataBind();        //if (Request.QueryString["highSearch"] != null)        //{        //    ds = dlProduct.GetList(Request.QueryString["highSearch"].ToString());        //}        //else        //{        //    ds = dlProduct.GetAllList();        //}        #region 为产品列表dlProduct分页做准备        ViewState["ds"] = ds;        pds.DataSource = ds.Tables[0].DefaultView;        pds.AllowPaging = true;        pds.PageSize = 10;        int CurPage = 0;        //            ViewState["CurPage"]="0";        if (ViewState["CurPage"] != null)        {            CurPage = int.Parse(ViewState["CurPage"].ToString());        }        else        {            ViewState["CurPage"] = "0";            CurPage = 0;        }        pds.CurrentPageIndex = CurPage;//当前页是从0开始算的.所以要-1        this.lblCurrentPage.Text = "第1页";        int pageCount = 0;        if (ds.Tables[0].Rows.Count % pds.PageSize == 0)        {            pageCount = ds.Tables[0].Rows.Count / pds.PageSize;        }        else        {            pageCount = ds.Tables[0].Rows.Count / pds.PageSize + 1;        }        ViewState["pageCount"] = pageCount;        this.lblPageCount.Text = "共" + pageCount.ToString() + "页";        this.dlProduct.DataSource = pds;        dlProduct.DataKeyField = "NewsID";        this.dlProduct.DataBind();        #endregion        ViewState["ds"] = ds;    }    public void PageChange()    {        pds.DataSource = ds.Tables[0].DefaultView;        pds.AllowPaging = true;        pds.PageSize = 10;        int CurPage = 0;        ViewState["CurPage"] = "0";        if (ViewState["CurPage"] != null)        {            CurPage = int.Parse(ViewState["CurPage"].ToString());        }        else        {            ViewState["CurPage"] = "0";            CurPage = 0;        }        pds.CurrentPageIndex = CurPage;//当前页是从0开始算的.所以要-1        this.lblCurrentPage.Text = "第1页";        int pageCount = 0;        if (ds.Tables[0].Rows.Count % pds.PageSize == 0)        {            pageCount = ds.Tables[0].Rows.Count / pds.PageSize;        }        else        {            pageCount = ds.Tables[0].Rows.Count / pds.PageSize + 1;        }        ViewState["pageCount"] = pageCount;        this.lblPageCount.Text = "共" + pageCount.ToString() + "页";        this.dlProduct.DataSource = pds;        dlProduct.DataKeyField = "NewsID";        this.dlProduct.DataBind();        if (ds.Tables[0].Rows.Count == 0)        {            lblCurrentPage.Text = "";            this.lbtnOne.Enabled = false;            this.lbtnPre.Enabled = false;            this.lbtnLast.Enabled = false;            this.lbtnNext.Enabled = false;            this.txtCurrentPage.Enabled = false;            this.btnGO.Enabled = false;        }        else        {            this.lbtnOne.Enabled = true;            this.lbtnPre.Enabled = true;            this.lbtnLast.Enabled = true;            this.lbtnNext.Enabled = true;            this.txtCurrentPage.Enabled = true;            this.btnGO.Enabled = true;        }        //iframe自适应所加载页面大小        Response.Write("<script>parent.document.getElementById('iframeGO').style.height=document.body.scrollHeight;</script>");    }    protected void lbtnOne_Click(object sender, EventArgs e)    {        BindPage(0);        ViewState["CurPage"] = "0";        this.lblCurrentPage.Text = "第1页";        if (this.lblCurrentPage.Text == "第1页")        {            this.lbtnPre.Enabled = false;            this.lbtnOne.Enabled = false;        }        else        {            this.lbtnPre.Enabled = true;            this.lbtnOne.Enabled = true;        }        if (this.lblCurrentPage.Text == "第" + ViewState["pageCount"].ToString() + "页")        {            this.lbtnLast.Enabled = false;            this.lbtnNext.Enabled = false;        }        else        {            this.lbtnLast.Enabled = true;            this.lbtnNext.Enabled = true;        }    }    protected void lbtnPre_Click(object sender, EventArgs e)    {        ds = (DataSet)ViewState["ds"];        //PageDataSource 是vs提供的分页控件 .可以直接使用        PagedDataSource pds = new PagedDataSource();        pds.DataSource = ds.Tables[0].DefaultView;        pds.AllowPaging = true;        pds.PageSize = 10;        int CurPage = int.Parse(ViewState["CurPage"].ToString());        if (ViewState["CurPage"].ToString() == "0")        {            //Jscript.AlertAndRedirect(this, "已是首页!");//当前页是从0开始算的.所以要-1            //return;        }        else        {            pds.CurrentPageIndex = int.Parse(ViewState["CurPage"].ToString()) - 1;            CurPage--;        }        this.dlProduct.DataSource = pds;        dlProduct.DataKeyField = "NewsID";        this.dlProduct.DataBind();        ViewState["CurPage"] = CurPage;        this.lblCurrentPage.Text = "第" + (int.Parse(ViewState["CurPage"].ToString()) + 1).ToString() + "页";        if (this.lblCurrentPage.Text == "第1页")        {            this.lbtnPre.Enabled = false;            this.lbtnOne.Enabled = false;        }        else        {            this.lbtnPre.Enabled = true;            this.lbtnOne.Enabled = true;        }        if (this.lblCurrentPage.Text == "第" + ViewState["pageCount"].ToString() + "页")        {            this.lbtnLast.Enabled = false;            this.lbtnNext.Enabled = false;        }        else        {            this.lbtnLast.Enabled = true;            this.lbtnNext.Enabled = true;        }    } 


[解决办法]

C# code
  protected void lbtnNext_Click(object sender, EventArgs e)    {        ds = (DataSet)ViewState["ds"];        //PageDataSource 是vs提供的分页控件 .可以直接使用        PagedDataSource pds = new PagedDataSource();        pds.DataSource = ds.Tables[0].DefaultView;        pds.AllowPaging = true;        pds.PageSize = 10;        int CurPage = int.Parse(ViewState["CurPage"].ToString());        if (CurPage == int.Parse(ViewState["pageCount"].ToString()) - 1)        {            //MessageBox.Show(this, "已达末页");            //return;        }        else        {            pds.CurrentPageIndex = int.Parse(ViewState["CurPage"].ToString()) + 1;            CurPage++;        }        this.dlProduct.DataSource = pds;        dlProduct.DataKeyField = "NewsID";        this.dlProduct.DataBind();        ViewState["CurPage"] = CurPage;        this.lblCurrentPage.Text = "第" + (int.Parse(ViewState["CurPage"].ToString()) + 1).ToString() + "页";        if (this.lblCurrentPage.Text == "第1页")        {            this.lbtnPre.Enabled = false;            this.lbtnOne.Enabled = false;        }        else        {            this.lbtnPre.Enabled = true;            this.lbtnOne.Enabled = true;        }        if (this.lblCurrentPage.Text == "第" + ViewState["pageCount"].ToString() + "页")        {            this.lbtnLast.Enabled = false;            this.lbtnNext.Enabled = false;        }        else        {            this.lbtnLast.Enabled = true;            this.lbtnNext.Enabled = true;        }    }    protected void lbtnLast_Click(object sender, EventArgs e)    {        BindPage(int.Parse(ViewState["pageCount"].ToString()) - 1);        ViewState["CurPage"] = (int.Parse(ViewState["pageCount"].ToString()) - 1).ToString();        this.lblCurrentPage.Text = "第" + ViewState["pageCount"].ToString() + "页";        if (this.lblCurrentPage.Text == "第1页")        {            this.lbtnPre.Enabled = false;            this.lbtnOne.Enabled = false;        }        else        {            this.lbtnPre.Enabled = true;            this.lbtnOne.Enabled = true;        }        if (this.lblCurrentPage.Text == "第" + ViewState["pageCount"].ToString() + "页")        {            this.lbtnLast.Enabled = false;            this.lbtnNext.Enabled = false;        }        else        {            this.lbtnLast.Enabled = true;            this.lbtnNext.Enabled = true;        }    }    protected void btnGO_Click(object sender, EventArgs e)    {        if (this.txtCurrentPage.Text == string.Empty)        {            //MessageBox.Show(this, "请输入页码!");            //MessageBox.Show(this, "请输入页码!");        }        else        {            if (int.Parse(this.txtCurrentPage.Text) > 0 && int.Parse(this.txtCurrentPage.Text) <= int.Parse(ViewState["pageCount"].ToString()))            {                BindPage(int.Parse(this.txtCurrentPage.Text) - 1);            }            else            {                //MessageBox.Show(this, "不存在此页!");                //MessageBox.Show(this, "不存在此页!");            }            if (int.Parse(this.txtCurrentPage.Text) == 1 && int.Parse(ViewState["pageCount"].ToString()) > 1)            {                this.lbtnOne.Enabled = false;                this.lbtnPre.Enabled = false;                this.lbtnLast.Enabled = true;                this.lbtnNext.Enabled = true;            }            if (int.Parse(this.txtCurrentPage.Text) == int.Parse(ViewState["pageCount"].ToString()) && int.Parse(ViewState["pageCount"].ToString()) > 1)            {                this.lbtnLast.Enabled = false;                this.lbtnNext.Enabled = false;                this.lbtnOne.Enabled = true;                this.lbtnPre.Enabled = true;            }        }    }    protected void BindPage(int iPageIndex)    {        //绑定产品        DataSet ds = new DataSet();        ds = (DataSet)ViewState["ds"];        //PageDataSource 是vs提供的分页控件 .可以直接使用        PagedDataSource pds = new PagedDataSource();        pds.DataSource = ds.Tables[0].DefaultView;        pds.AllowPaging = true;        pds.PageSize = 10;        pds.CurrentPageIndex = iPageIndex;//当前页是从0开始算的.所以要-1        this.lblCurrentPage.Text = "第" + (iPageIndex + 1).ToString() + "页";        this.dlProduct.DataSource = pds;        dlProduct.DataKeyField = "NewsID";        this.dlProduct.DataBind();        ViewState["CurPage"] = iPageIndex.ToString();        //Response.Write("<script>parent.document.getElementById('iframeGO').style.height=document.body.scrollHeight;</script>");    }} 


[解决办法]
ls的朋友好热情 jf

热点排行