By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,391 Members | 1,387 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,391 IT Pros & Developers. It's quick & easy.

How to allow paging in grid view control

P: 16
Hi Guys,
Please Help ME....
I have a problem in displaying data in my gridview with paging, the data from the database is displaying to my gridview but I want to allow paging in my gridview.how can I do that?
I got an error msg that datareader does not allow paging in gridview....
because I use datareader in binding my data.
How can I convert my datareader to datatable using VB script so that I can allow paging to my Gridview?

I'm Using ASP.net and MS SQL2005 and I'm using VB SCRIPT

Here is my code:
Expand|Select|Wrap|Line Numbers
  1.  Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs)
  2.      Dim con As New SqlConnection
  3.  
  4.         con.ConnectionString = "Integrated Security=True;data source=ph-erwinm1;" & "persist security info=false;Initial Catalog=ITP"
  5.  
  6.         Const strSQL As String = "SELECT intITPCodePK,strsubmitter,datRequested,datRequired FROM tblITPtransaction"
  7.         Dim myCommand As New SqlCommand(strSQL, con)
  8.               con.Open()
  9.         GridITPSumm.DataSource = myCommand.ExecuteReader(CommandBehavior.CloseConnection)
  10.         GridITPSumm.DataBind()
  11.  
  12. end sub
  13.  
  14.  
  15.  
  16. ----------HTML-------------
  17.  
  18. <asp:GridView id="GridITPSumm" runat="server" Width="606px" Height="18px" ForeColor="#333333" AllowSorting="True" AllowPaging="false" CellPadding="4" AutoGenerateColumns="False" Font-Size="Smaller" Font-Overline="False" Font-Names="Arial" EnableViewState="False" Font-Bold="False" style="left: 2px; position: relative; top: -33px">
  19. <FooterStyle BackColor="#507CD1" ForeColor="White" Font-Bold="True"></FooterStyle>
  20. <Columns>
  21. <asp:BoundField DataField="intITPCodePK" SortExpression="intITPCodePK" HeaderText="ITP Code"></asp:BoundField>
  22. <asp:BoundField DataField="strsubmitter" SortExpression="strsubmitter" HeaderText="Submitter"></asp:BoundField>
  23. <asp:BoundField DataField="datRequested" SortExpression="datRequested" HeaderText="Date Requested"></asp:BoundField>
  24. <asp:BoundField DataField="datRequired" SortExpression="datRequired" HeaderText="Date Required"></asp:BoundField>
  25.  
  26. </Columns>
  27.  
  28. <RowStyle BackColor="#EFF3FB"></RowStyle>
  29.  
  30. <EditRowStyle BackColor="#2461BF"></EditRowStyle>
  31.  
  32. <SelectedRowStyle BackColor="#D1DDF1" ForeColor="#333333" Font-Bold="True"></SelectedRowStyle>
  33.  
  34. <PagerStyle BackColor="#2461BF" ForeColor="White" HorizontalAlign="Center"></PagerStyle>
  35.  
  36. <HeaderStyle BackColor="#507CD1" ForeColor="White" Font-Bold="True"></HeaderStyle>
  37.  
  38. <AlternatingRowStyle BackColor="White"></AlternatingRowStyle>
  39. </asp:GridView>



Thank You Guys in Advance....
Help Me Please....
Feb 23 '08 #1
Share this Question
Share on Google+
2 Replies


kenobewan
Expert 2.5K+
P: 4,871
Here is an example that may help:
GridView
Feb 23 '08 #2

P: 16
Here is an example that may help:
GridView
Thank You for your effort but still my problem is not answered.
I want to hard code it, I don't want to use wizard. My Problem is I'm using sqldatareader in binding data, many programmer said that you cannot edit or select or allow paging your gridview in using sqldatareader in binding data.
what should I do? Is there other way in binding data to gridview control so that i can select or allow paging in may gridview control.

thank you...
please help
Feb 25 '08 #3

Post your reply

Sign in to post your reply or Sign up for a free account.