468,133 Members | 1,168 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,133 developers. It's quick & easy.

How to allow paging in grid view control

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
2 2478
kenobewan
4,871 Expert 4TB
Here is an example that may help:
GridView
Feb 23 '08 #2
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.

Similar topics

2 posts views Thread by Luis Esteban Valencia | last post: by
2 posts views Thread by Daniel Walzenbach | last post: by
reply views Thread by Raed Sawalha | last post: by
1 post views Thread by the friendly display name | last post: by
2 posts views Thread by rn5a | last post: by
reply views Thread by news.ipartners.pl | last post: by
7 posts views Thread by =?Utf-8?B?TG9zdEluTUQ=?= | last post: by
1 post views Thread by =?Utf-8?B?TG95b2xhIHN0YWxpbg==?= | last post: by
27 posts views Thread by didacticone | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.