日期:2014-05-18  浏览次数:20418 次

gridview 自定义分页在转到某页时无数据,在线等,谢谢
问题:在goto   page   中任意选一个数字后,gridview中没有数据出来.但用first   next   等按钮操作翻页则可以.
代码:listnews.aspx:
<%@   Page   Language= "C# "   AutoEventWireup= "true "   CodeFile= "Listnews.aspx.cs "   Inherits= "Listnews "   %>

<!DOCTYPE   html   PUBLIC   "-//W3C//DTD   XHTML   1.0   Transitional//EN "   "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd ">

<html   xmlns= "http://www.w3.org/1999/xhtml "   >
<head   runat= "server ">
        <title> 无标题页 </title>
</head>
<body>
        <form   id= "form1 "   runat= "server ">
        <div>
                        <asp:GridView   ID= "gvNewsLists "   runat= "server "   AllowPaging= "True "   AllowSorting= "True "
                        AutoGenerateColumns= "False "   CellPadding= "4 "   ForeColor= "#333333 "   GridLines= "None "
                        Width= "100% "   DataKeyNames= "newsid "   OnPageIndexChanging= "gvNewsLists_PageIndexChanging "   OnRowEditing= "gvNewsLists_RowEditing "   OnRowUpdating= "gvNewsLists_RowUpdating "   OnSorting= "gvNewsLists_Sorting "   PageSize= "20 "   OnRowCancelingEdit= "gvNewsLists_RowCancelingEdit "   OnRowCommand= "gvNewsLists_RowCommand "   OnRowCreated= "GridView1_RowCreated ">
                        <FooterStyle   BackColor= "#990000 "   Font-Bold= "True "   ForeColor= "White "   />
                        <Columns>
                                <asp:BoundField   DataField= "newsid "   HeaderText= "news   id "   ReadOnly= "True "   />
                                <asp:BoundField   DataField= "topic "   HeaderText= "topic "   SortExpression= "topic "   />
                                <asp:BoundField   DataField= "ntime "   HeaderText= "ntime "   SortExpression= "ntime "   />
                                <asp:ButtonField   Text= "Delete "   ButtonType= "Button "   CommandName= "Delete "   />
                                <asp:ButtonField   Text= "Edit "   ButtonType= "Button "   CommandName= "Edit "   />
          &nb