Wrox Home  
Search P2P Archive for: Go

  Return to Index  

aspdotnet_website_programming thread: Paging Problem!


Message #1 by Shaho Toofani <shaho59@y...> on Wed, 28 Aug 2002 01:45:01 -0700 (PDT)
Dear Developers
I want to make a datagrid with numerical paging that retrieve an ID from 
querystring and fill datareader.
My datagrid pagesize is set to 2, and i have more than 35 records in database
but when i run the code, datagrid display only 2 records and only No. 1 for the
paging and other pages+numerical numbers would be lost(not displaying)
Here, is my snipt.
Please help me,
Thanks for your cooperation.
Shaho


Sub Page_Load(Source As Object, E As EventArgs)
 If Not IsPostBack Then
   bindDataGrid
 End If
End Sub
Sub bindDataGrid
   Dim myConn As OleDbConnection
   Dim myOleDbDataReader As OleDbDataReader
   Dim myOleDbCommand As OleDbCommand
   Dim connStr, sqlStr As String
   Dim intCat As Integer
 intCat=Int32.Parse(Request.QueryString("id"))

        connStr="Provider=Microsoft.Jet.OLEDB.4.0; " _
                + "Data Source=D:\inetpub\wwwroot\me2\db\db.mdb"
   
        sqlStr = "SELECT  article_title, article_author, cat_caption " _
              +   " FROM Articles Where article_category=@article_category"
   myConn= New OleDbConnection(connStr)
   myConn.Open()
   myOleDbCommand=New OleDbCommand(sqlStr,myConn)
   myOleDbCommand.Parameters.Add("@article_category", intCat)
   MyOleDbDataReader=myOleDbCommand.ExecuteReader()
   dataGrid1.DataSource = MyOleDbDataReader
   dataGrid1.DataBind()
   MyOleDbDataReader.Close()
   myConn.Close()
 End Sub
 Sub doPaging(s As Object, e As DataGridPageChangedEventArgs)
     dataGrid1.CurrentPageIndex = e.NewPageIndex
     bindDataGrid
  End Sub
</script>
<html><head></head><form runat="server">
<asp:DataGrid runat="server" id="dataGrid1"
     AutoGenerateColumns="true"
  AllowCustomPaging="true"
     AllowPaging="true"
     PageSize="2"
     PagerStyle-Mode="NumericPages"
     PagerStyle-HorizontalAlign="Center"
     OnPageIndexChanged="doPaging"
     BackColor="White"
     BorderWidth="1px" BorderStyle="Solid" 
     Width="100%"
     BorderColor="Salmon"
     CellPadding="2" CellSpacing="0"
     Font-Name="Verdana" Font-Size="8pt">
    <HeaderStyle Font-Size="8" Font-Names="Arial" 
             Font-Bold="True" BackColor="Yellow"
             HorizontalAlign="center">
    </HeaderStyle> 
    <AlternatingItemStyle BackColor="Beige"/>
</asp:DataGrid>
</center></form></html>



---------------------------------
Do You Yahoo!?
Yahoo! Finance - Get real-time stock quotes

  Return to Index