Hi!
I have a girdview that use oracle database, the result is more than more page, how could I show the result in many page?
I used AllowPaging="Tr ue", but the just the result of page one was right and for other pages I'v got this error:
"Serverfeil i programmet /Totalsalg.
GridView GridView1 started PageIndexChangi ng that is handeld."
Please help me.
<asp:GridView ID="GridView1" runat="server" AllowPaging="Tr ue" AllowSorting="F alse" GridLines="None "
AutoGenerateCol umns="False" CellPadding="6" >
<RowStyle BackColor="#FFF FFF" />
<AlternatingRow Style BackColor="#CCC CCC" />
<Columns>
<asp:BoundFie ld DataField="QUAN TITY" HeaderText="Ant all" ReadOnly="True" AccessibleHeade rText="false" SortExpression= "QUANTITY" ItemStyle-HorizontalAlign ="Right" />
<asp:BoundFie ld DataField="SUMN OK" DataFormatStrin g="{0:n0}" HtmlEncode="fal se" HeaderText="Pri s" ReadOnly="True" AccessibleHeade rText="false" SortExpression= "SUMNOK" ItemStyle-HorizontalAlign ="Right" />
<asp:BoundFie ld DataField="RegD ate" HeaderText="Dat o" ReadOnly="True" AccessibleHeade rText="False" SortExpression= "RegDate" />
</Columns>
</asp:GridView>
protected void Page_Load(objec t sender, EventArgs e)
{
if (!Page.IsPostBa ck)
{
OracleConnectio n MyConnection;
OracleCommand MyCommand;
OracleDataAdapt er MyAdaptor;
DataTable MyTable = new DataTable();
MyConnection = new OracleConnectio n();
MyConnection.Co nnectionString = ConfigurationMa nager.Connectio nStrings["TestDB"].ConnectionStri ng;
MyCommand = new OracleCommand() ;
MyCommand.Comma ndText = "Select sum(o.quantity) as Quantity, SUM(o.quantity* s.price) as SumNOK, SUBSTR(o.regdat e,7,4)||'-'||SUBSTR(o.reg date,1,2)||'-'||SUBSTR(o.reg date,4,2) as RegDate FROM shamrock.cat_or der o, shamrock.cat_sa lesproduct s WHERE o.salesproductI d=s.salesproduc tnum GROUP BY SUBSTR(o.regdat e,7,4)||'-'||SUBSTR(o.reg date,1,2)||'-'||SUBSTR(o.reg date,4,2)";
MyCommand.Comma ndType = CommandType.Tex t;
MyCommand.Conne ction = MyConnection;
MyAdaptor = new OracleDataAdapt er();
MyAdaptor.Selec tCommand = MyCommand;
MyAdaptor.Fill( MyTable);
GridView1.DataS ource = new DataView(MyTabl e, String.Empty, "REGDATE DESC", DataViewRowStat e.CurrentRows);
GridView1.DataB ind();
MyAdaptor.Dispo se();
MyCommand.Dispo se();
MyConnection.Di spose();
}
}
I have a girdview that use oracle database, the result is more than more page, how could I show the result in many page?
I used AllowPaging="Tr ue", but the just the result of page one was right and for other pages I'v got this error:
"Serverfeil i programmet /Totalsalg.
GridView GridView1 started PageIndexChangi ng that is handeld."
Please help me.
<asp:GridView ID="GridView1" runat="server" AllowPaging="Tr ue" AllowSorting="F alse" GridLines="None "
AutoGenerateCol umns="False" CellPadding="6" >
<RowStyle BackColor="#FFF FFF" />
<AlternatingRow Style BackColor="#CCC CCC" />
<Columns>
<asp:BoundFie ld DataField="QUAN TITY" HeaderText="Ant all" ReadOnly="True" AccessibleHeade rText="false" SortExpression= "QUANTITY" ItemStyle-HorizontalAlign ="Right" />
<asp:BoundFie ld DataField="SUMN OK" DataFormatStrin g="{0:n0}" HtmlEncode="fal se" HeaderText="Pri s" ReadOnly="True" AccessibleHeade rText="false" SortExpression= "SUMNOK" ItemStyle-HorizontalAlign ="Right" />
<asp:BoundFie ld DataField="RegD ate" HeaderText="Dat o" ReadOnly="True" AccessibleHeade rText="False" SortExpression= "RegDate" />
</Columns>
</asp:GridView>
protected void Page_Load(objec t sender, EventArgs e)
{
if (!Page.IsPostBa ck)
{
OracleConnectio n MyConnection;
OracleCommand MyCommand;
OracleDataAdapt er MyAdaptor;
DataTable MyTable = new DataTable();
MyConnection = new OracleConnectio n();
MyConnection.Co nnectionString = ConfigurationMa nager.Connectio nStrings["TestDB"].ConnectionStri ng;
MyCommand = new OracleCommand() ;
MyCommand.Comma ndText = "Select sum(o.quantity) as Quantity, SUM(o.quantity* s.price) as SumNOK, SUBSTR(o.regdat e,7,4)||'-'||SUBSTR(o.reg date,1,2)||'-'||SUBSTR(o.reg date,4,2) as RegDate FROM shamrock.cat_or der o, shamrock.cat_sa lesproduct s WHERE o.salesproductI d=s.salesproduc tnum GROUP BY SUBSTR(o.regdat e,7,4)||'-'||SUBSTR(o.reg date,1,2)||'-'||SUBSTR(o.reg date,4,2)";
MyCommand.Comma ndType = CommandType.Tex t;
MyCommand.Conne ction = MyConnection;
MyAdaptor = new OracleDataAdapt er();
MyAdaptor.Selec tCommand = MyCommand;
MyAdaptor.Fill( MyTable);
GridView1.DataS ource = new DataView(MyTabl e, String.Empty, "REGDATE DESC", DataViewRowStat e.CurrentRows);
GridView1.DataB ind();
MyAdaptor.Dispo se();
MyCommand.Dispo se();
MyConnection.Di spose();
}
}
Comment