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:
[code=vbnet]
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArg s)
Dim con As New SqlConnection
con.ConnectionS tring = "Integrated Security=True;d ata source=ph-erwinm1;" & "persist security info=false;Init ial Catalog=ITP"
Const strSQL As String = "SELECT intITPCodePK,st rsubmitter,datR equested,datReq uired FROM tblITPtransacti on"
Dim myCommand As New SqlCommand(strS QL, con)
con.Open()
GridITPSumm.Dat aSource = myCommand.Execu teReader(Comman dBehavior.Close Connection)
GridITPSumm.Dat aBind()
end sub
----------HTML-------------
<asp:GridView id="GridITPSumm " runat="server" Width="606px" Height="18px" ForeColor="#333 333" AllowSorting="T rue" AllowPaging="fa lse" CellPadding="4" AutoGenerateCol umns="False" Font-Size="Smaller" Font-Overline="False " Font-Names="Arial" EnableViewState ="False" Font-Bold="False" style="left: 2px; position: relative; top: -33px">
<FooterStyle BackColor="#507 CD1" ForeColor="Whit e" Font-Bold="True"></FooterStyle>
<Columns>
<asp:BoundFie ld DataField="intI TPCodePK" SortExpression= "intITPCode PK" HeaderText="ITP Code"></asp:BoundField>
<asp:BoundFie ld DataField="strs ubmitter" SortExpression= "strsubmitt er" HeaderText="Sub mitter"></asp:BoundField>
<asp:BoundFie ld DataField="datR equested" SortExpression= "datRequest ed" HeaderText="Dat e Requested"></asp:BoundField>
<asp:BoundFie ld DataField="datR equired" SortExpression= "datRequire d" HeaderText="Dat e Required"></asp:BoundField>
</Columns>
<RowStyle BackColor="#EFF 3FB"></RowStyle>
<EditRowStyle BackColor="#246 1BF"></EditRowStyle>
<SelectedRowSty le BackColor="#D1D DF1" ForeColor="#333 333" Font-Bold="True"></SelectedRowStyl e>
<PagerStyle BackColor="#246 1BF" ForeColor="Whit e" HorizontalAlign ="Center"></PagerStyle>
<HeaderStyle BackColor="#507 CD1" ForeColor="Whit e" Font-Bold="True"></HeaderStyle>
<AlternatingRow Style BackColor="Whit e"></AlternatingRowS tyle>
</asp:GridView>[/code]
Thank You Guys in Advance....
Help Me Please....
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:
[code=vbnet]
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArg s)
Dim con As New SqlConnection
con.ConnectionS tring = "Integrated Security=True;d ata source=ph-erwinm1;" & "persist security info=false;Init ial Catalog=ITP"
Const strSQL As String = "SELECT intITPCodePK,st rsubmitter,datR equested,datReq uired FROM tblITPtransacti on"
Dim myCommand As New SqlCommand(strS QL, con)
con.Open()
GridITPSumm.Dat aSource = myCommand.Execu teReader(Comman dBehavior.Close Connection)
GridITPSumm.Dat aBind()
end sub
----------HTML-------------
<asp:GridView id="GridITPSumm " runat="server" Width="606px" Height="18px" ForeColor="#333 333" AllowSorting="T rue" AllowPaging="fa lse" CellPadding="4" AutoGenerateCol umns="False" Font-Size="Smaller" Font-Overline="False " Font-Names="Arial" EnableViewState ="False" Font-Bold="False" style="left: 2px; position: relative; top: -33px">
<FooterStyle BackColor="#507 CD1" ForeColor="Whit e" Font-Bold="True"></FooterStyle>
<Columns>
<asp:BoundFie ld DataField="intI TPCodePK" SortExpression= "intITPCode PK" HeaderText="ITP Code"></asp:BoundField>
<asp:BoundFie ld DataField="strs ubmitter" SortExpression= "strsubmitt er" HeaderText="Sub mitter"></asp:BoundField>
<asp:BoundFie ld DataField="datR equested" SortExpression= "datRequest ed" HeaderText="Dat e Requested"></asp:BoundField>
<asp:BoundFie ld DataField="datR equired" SortExpression= "datRequire d" HeaderText="Dat e Required"></asp:BoundField>
</Columns>
<RowStyle BackColor="#EFF 3FB"></RowStyle>
<EditRowStyle BackColor="#246 1BF"></EditRowStyle>
<SelectedRowSty le BackColor="#D1D DF1" ForeColor="#333 333" Font-Bold="True"></SelectedRowStyl e>
<PagerStyle BackColor="#246 1BF" ForeColor="Whit e" HorizontalAlign ="Center"></PagerStyle>
<HeaderStyle BackColor="#507 CD1" ForeColor="Whit e" Font-Bold="True"></HeaderStyle>
<AlternatingRow Style BackColor="Whit e"></AlternatingRowS tyle>
</asp:GridView>[/code]
Thank You Guys in Advance....
Help Me Please....
Comment