473,396 Members | 2,010 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

gridview paging in .net 2.0 and c# with oracle data base

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="True", 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 PageIndexChanging that is handeld."

Please help me.

<asp:GridView ID="GridView1" runat="server" AllowPaging="True" AllowSorting="False" GridLines="None"
AutoGenerateColumns="False" CellPadding="6" >
<RowStyle BackColor="#FFFFFF" />
<AlternatingRowStyle BackColor="#CCCCCC" />
<Columns>
<asp:BoundField DataField="QUANTITY" HeaderText="Antall" ReadOnly="True" AccessibleHeaderText="false" SortExpression="QUANTITY" ItemStyle-HorizontalAlign="Right" />
<asp:BoundField DataField="SUMNOK" DataFormatString="{0:n0}" HtmlEncode="false" HeaderText="Pris" ReadOnly="True" AccessibleHeaderText="false" SortExpression="SUMNOK" ItemStyle-HorizontalAlign="Right" />
<asp:BoundField DataField="RegDate" HeaderText="Dato" ReadOnly="True" AccessibleHeaderText="False" SortExpression="RegDate" />
</Columns>
</asp:GridView>


protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{

OracleConnection MyConnection;
OracleCommand MyCommand;
OracleDataAdapter MyAdaptor;
DataTable MyTable = new DataTable();

MyConnection = new OracleConnection();
MyConnection.ConnectionString = ConfigurationManager.ConnectionStrings["TestDB"].ConnectionString;


MyCommand = new OracleCommand();
MyCommand.CommandText = "Select sum(o.quantity) as Quantity, SUM(o.quantity*s.price) as SumNOK, SUBSTR(o.regdate,7,4)||'-'||SUBSTR(o.regdate,1,2)||'-'||SUBSTR(o.regdate,4,2) as RegDate FROM shamrock.cat_order o, shamrock.cat_salesproduct s WHERE o.salesproductId=s.salesproductnum GROUP BY SUBSTR(o.regdate,7,4)||'-'||SUBSTR(o.regdate,1,2)||'-'||SUBSTR(o.regdate,4,2)";
MyCommand.CommandType = CommandType.Text;
MyCommand.Connection = MyConnection;


MyAdaptor = new OracleDataAdapter();
MyAdaptor.SelectCommand = MyCommand;
MyAdaptor.Fill(MyTable);

GridView1.DataSource = new DataView(MyTable, String.Empty, "REGDATE DESC", DataViewRowState.CurrentRows);
GridView1.DataBind();

MyAdaptor.Dispose();
MyCommand.Dispose();
MyConnection.Dispose();

}
}
Jun 6 '07 #1
7 6644
shweta123
692 Expert 512MB
Hi,

Your error message is not clear. Are you getting the error when you are changing the Page Index?

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="True", 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 PageIndexChanging that is handeld."

Please help me.

<asp:GridView ID="GridView1" runat="server" AllowPaging="True" AllowSorting="False" GridLines="None"
AutoGenerateColumns="False" CellPadding="6" >
<RowStyle BackColor="#FFFFFF" />
<AlternatingRowStyle BackColor="#CCCCCC" />
<Columns>
<asp:BoundField DataField="QUANTITY" HeaderText="Antall" ReadOnly="True" AccessibleHeaderText="false" SortExpression="QUANTITY" ItemStyle-HorizontalAlign="Right" />
<asp:BoundField DataField="SUMNOK" DataFormatString="{0:n0}" HtmlEncode="false" HeaderText="Pris" ReadOnly="True" AccessibleHeaderText="false" SortExpression="SUMNOK" ItemStyle-HorizontalAlign="Right" />
<asp:BoundField DataField="RegDate" HeaderText="Dato" ReadOnly="True" AccessibleHeaderText="False" SortExpression="RegDate" />
</Columns>
</asp:GridView>


protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{

OracleConnection MyConnection;
OracleCommand MyCommand;
OracleDataAdapter MyAdaptor;
DataTable MyTable = new DataTable();

MyConnection = new OracleConnection();
MyConnection.ConnectionString = ConfigurationManager.ConnectionStrings["TestDB"].ConnectionString;


MyCommand = new OracleCommand();
MyCommand.CommandText = "Select sum(o.quantity) as Quantity, SUM(o.quantity*s.price) as SumNOK, SUBSTR(o.regdate,7,4)||'-'||SUBSTR(o.regdate,1,2)||'-'||SUBSTR(o.regdate,4,2) as RegDate FROM shamrock.cat_order o, shamrock.cat_salesproduct s WHERE o.salesproductId=s.salesproductnum GROUP BY SUBSTR(o.regdate,7,4)||'-'||SUBSTR(o.regdate,1,2)||'-'||SUBSTR(o.regdate,4,2)";
MyCommand.CommandType = CommandType.Text;
MyCommand.Connection = MyConnection;


MyAdaptor = new OracleDataAdapter();
MyAdaptor.SelectCommand = MyCommand;
MyAdaptor.Fill(MyTable);

GridView1.DataSource = new DataView(MyTable, String.Empty, "REGDATE DESC", DataViewRowState.CurrentRows);
GridView1.DataBind();

MyAdaptor.Dispose();
MyCommand.Dispose();
MyConnection.Dispose();

}
}
Jun 6 '07 #2
Yes, when I want to see other pages,I'v got error.
Jun 6 '07 #3
Yes, when I want to see other pages,I'v got error.
Jun 6 '07 #4
Vidhura
99
Hope the following helps

1.Add PageIndexChanging event
<asp:GridView ID="GridView1" runat="server" Height="539px" AllowPaging="True"
Width="628px" OnPageIndexChanging="GridView1_PageIndexChanging">
</asp:GridView>

2.Assign newpageindex to the gridview in the event
protected void GridView1_PageIndexChanging(object sender, GridViewPageEventArgs e)
{
GridView1.PageIndex = e.NewPageIndex;
GridView1.DataBind();

}
Jun 6 '07 #5
I tried it and I didn't get the error again, but it works just for the first page and when I change the page, other page is empty!
Jun 6 '07 #6
Hi. please help me about paging.
Jun 7 '07 #7
Vidhura
99
Hi. please help me about paging.
Hi ,the problem is with Ispostback

Remove the if condition and check
if (!Page.IsPostBack)
{}
Jun 7 '07 #8

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

Similar topics

0
by: ck388 | last post by:
For some reason when I enable the callback feature of the gridview I still get a page refresh, that is it seems like there is a postback that occurs, not a callback which is just supposed to update...
2
by: | last post by:
Hello, I have a GridView in my ASP.NET 2.0 application that performs the paging feature perfect when I have it bound to a data source. But now I have it bound to a dataset and the paging...
3
by: mazdotnet | last post by:
Hi everyone, I know when you enable paging in a datagrid the entire data is read but only the data that you want is displayed to the end user. Has this changed for Gridview? So if you have 10000...
6
by: GaryDean | last post by:
I liked the DataGrid because I was familiar in walking through it to do custom filling and retrieval of data in cases where standard binding wouldn't do the job. I read somewhere that the object...
8
by: Greg Lyles | last post by:
Hi all, I'm trying to develop an ASP.NET 2.0 website and am running into some real problems with what I thought would be a relatively simple thing to do. In a nutshell, I'm stuck on trying to...
2
by: antonyliu2002 | last post by:
I've been googling for some time, and could not find the solution to this problem. I am testing the paging feature of gridview. I have a very simple web form on which the user can select a few...
5
by: Andrew Robinson | last post by:
I am attempting to better automate a Pager Template within a GridView. I am succesfully skinning a Drop Down List withing my control (the DDL is added to my control). I correctly populate the item...
0
by: Don Miller | last post by:
Here is an example of what I believe is a bug in ASP.NET 2.0 GridView paging without postbacks (or at least not documented how to fix it). Once the GridView is displayed, clicking on any of the...
4
by: Don Miller | last post by:
This is a repost of a reproducible problem/bug with GridView with dynamic SQL and binding. Is there a better ASP.NET newsgroup I should post to where MS techs or MVPs take an interest in such...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.