2011-06-03 80 views
2

我的GridView:尋呼在GridView控件

   <asp:GridView ID="gridView1" runat="server" CellPadding="4" AllowPaging="true" PageSize="5" emptydatatext="No data available." 
        CssClass="datagrid" 
        ForeColor="#333333" GridLines="None" 
        onrowcreated="gridView1_RowCreated" 
        onpageindexchanging="gridView1_PageIndexChanging"> 

        <AlternatingRowStyle BackColor="White" ForeColor="#284775" /> 
        <EditRowStyle BackColor="#999999" /> 
        <FooterStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" /> 
        <HeaderStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" /> 
        <PagerStyle BackColor="#284775" ForeColor="White" HorizontalAlign="Center" /> 
        <RowStyle BackColor="#F7F6F3" ForeColor="#333333" /> 
        <SelectedRowStyle BackColor="#E2DED6" Font-Bold="True" ForeColor="#333333" /> 
        <SortedAscendingCellStyle BackColor="#E9E7E2" /> 
        <SortedAscendingHeaderStyle BackColor="#506C8C" /> 
        <SortedDescendingCellStyle BackColor="#FFFDF8" /> 
        <SortedDescendingHeaderStyle BackColor="#6F8DAE" /> 
       </asp:GridView> 

而且我隱藏:

protected void gridView1_PageIndexChanging(object sender, GridViewPageEventArgs e) 
    { 
     gridView1.PageIndex = e.NewPageIndex; 
     BindDataGrid(); 
    } 



    protected void BindDataGrid() 
    { 

     DataSet ds = new DataSet(); 

     ds = dbM.GetInfo(name, mobilePhone, info1); //get info to BD and save in "ds" 

     gridView1.DataSource = ds; 
     gridView1.DataBind(); 
    } 

和 「尋呼」 不工作。它顯示前5行,但不顯示分頁數

有什麼問題???

請幫

感謝

回答

2

嘗試加入一些尋呼機設置GridView標籤:

<PagerSettings Mode="NextPreviousFirstLast" Position="TopAndBottom" /> 

如果這樣的作品,你可以把它改成你想要的外觀。有many choices,包括

  • FirstPageImageUrl
  • FirstPageText
  • LastPageImageUrl
  • LastPageText
  • 模式(如數字或 NumericFirstLast)
  • NextPageImageUrl
  • NextPageText
  • PageBut tonCount
  • 位置
  • PreviousPageImageUrl
  • PreviousPageText
  • Visible`
2

添加PagerSettings,物業到GridView的標記,並將其設置True

PagerSettings-Visible="true" 

編輯:但它應該是true默認情況下,所以我不知道如果th會改變什麼

2
Use **"PageIndexChanged"** 

protected void gridView1_PageIndexChanged(object sender, GridViewPageEventArgs e) 
     { 
      try 
      { 
       gridView1.PageIndex = e.NewPageIndex; 
       BindDataGrid(); 
    ; 
      } 
      catch (Exception ex) 
      { 
       Response.Write(ex.Message); 
      } 
     }