我有一个调用存储过程的分页程序,我不知道怎样才能在我点了“最后一页”按钮时,”下一页“和“最后一页”变灰,并且页数到达最后一页,请高手帮我看看是datagrid 的哪个属性。
/***************************************************************************************/
viewfenye.aspx的页面部分代码是这样的:
/***************************************************************************************/
                  <asp:Button id="btnfirst" style="Z-INDEX: 101; LEFT: 208px; POSITION: absolute; TOP: 379px" runat="server" Font-Names="宋体" Font-Size="12px" Height="21px" Width="68px" Text="第一页"></asp:Button>
<asp:Button id="btnPrev" style="Z-INDEX: 102; LEFT: 290px; POSITION: absolute; TOP: 379px" runat="server" Font-Names="宋体" Font-Size="12px" Height="21px" Width="66px" Text="上一页"></asp:Button>
<asp:Button id="btnNext" style="Z-INDEX: 103; LEFT: 368px; POSITION: absolute; TOP: 379px" runat="server" Font-Names="宋体" Font-Size="12px" Height="21px" Width="66px" Text="下一页"></asp:Button>
<asp:Button id="btnlast" style="Z-INDEX: 104; LEFT: 448px; POSITION: absolute; TOP: 379px" runat="server" Font-Names="宋体" Font-Size="12px" Height="21px" Width="66px" Text="最后一页"></asp:Button>
<asp:DataGrid id="DataGrid1" style="Z-INDEX: 105; LEFT: 202px; POSITION: absolute; TOP: 143px" runat="server" Height="126px" Width="289px" AllowCustomPaging="True" EnableViewState="False" PageSize="3" AllowPaging="True">
<PagerStyle Visible="False"></PagerStyle>
</asp:DataGrid></FONT>/********************************************************************************/
viewfenye.aspx.vb
/********************************************************************************/
Function RunSprocReturnDR(ByVal startpage As Integer, ByVal endpage As Integer)
        Dim conn As New SqlConnection()
        Dim mycmd As New SqlCommand()
        Dim i As Integer
        Dim parmReturnCount As SqlParameter
        conn.ConnectionString = "server=localhost;uid=sa;pwd=sa;database=ly"
        conn.Open()
        mycmd.CommandType = CommandType.StoredProcedure
        mycmd.Connection = conn
        mycmd.CommandText = "GetAuthors"
        mycmd.Parameters.Add("@StartRow", SqlDbType.Int).Value = startpage
        mycmd.Parameters.Add("@StopRow", SqlDbType.Int).Value = endpage
        parmReturnCount = mycmd.Parameters.Add("ReturnCount", SqlDbType.Int)
        parmReturnCount.Direction = ParameterDirection.ReturnValue        Dim result As SqlDataReader = mycmd.ExecuteReader
        viewstate("i") = CStr(mycmd.Parameters("ReturnCount").Value)
        RunSprocReturnDR = result    End Function    Private Sub btnNext_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnNext.Click
        viewstate("StartRow") = viewstate("StartRow") + DataGrid1.PageSize
        viewstate("StopRow") = viewstate("StartRow") + DataGrid1.PageSize - 1
        buttonEnable()
        '运行存储过程,返回SQLDataReader
        DataGrid1.DataSource = RunSprocReturnDR(viewstate("StartRow"), viewstate("StopRow"))
        DataGrid1.DataBind()
    End Sub    Private Sub btnPrev_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnPrev.Click
        viewstate("StopRow") = viewstate("StopRow") - DataGrid1.PageSize
        viewstate("StartRow") = viewstate("StopRow") - DataGrid1.PageSize + 1
        buttonEnable()
        '运行存储过程,返回SQLDataReader
        DataGrid1.DataSource = RunSprocReturnDR(viewstate("StartRow"), viewstate("StopRow"))
        DataGrid1.DataBind()
    End Sub    Private Sub btnfirst_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnfirst.Click
        viewstate("StartRow") = 1
        DataGrid1.DataSource = RunSprocReturnDR(1, DataGrid1.PageSize)
        DataGrid1.DataBind()
        setVisible(0, 1, 0, 1)
    End Sub    Private Sub btnlast_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnlast.Click
           ???????  
    End Sub/********************************************************************************/
  GetAuthors分页存储过程
/********************************************************************************/CREATE proc GetAuthors
--@name as varchar(100) = null,
@StartRow as int = null,
@StopRow as int = null
AS---- 建立有标识符列的table变量
declare @t_table table
(
[rownum] [int] IDENTITY (1, 1) Primary key NOT NULL ,
[name] [varchar] (40) ,
[liuyan] [varchar] (20)
)---- 在返回指定的@StopRow行数之后停止处理查询
Set RowCount @StopRow---- 插入到table变量中
insert @t_table
(
[name],[liuyan]
)
SELECT [name],[liuyan]
FROM liuyan
--WHERE name like '%' + @name + '%'
--ORDER BY name---- 返回到正确的结果
SELECT * FROM @t_table WHERE rownum >= @StartRow
ORDER BY rownum
return select count(id) from liuyan
GO