473,323 Members | 1,589 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,323 software developers and data experts.

DataView Sorting with Paging Question

I have a DataView sorting below with DataGrid and Dataset.
When i try implementing default Paging with the DataGrid it gives error
when i want to SORT:-

Error:-
"CurrentPageIndex value. It must be >= 0 and < the PageCount. "

CAN ANYBODY FORWARD ME AN EXAMPLE WHERE I CAN SORT THE TABLE AND AT THE
SAME TIME PAGE!
Thanks!
I have the code below:-

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
'Put user code to initialize the page here
If Not IsPostBack Then
With ddlAlpha
.Items.Add("A")
.Items.Add("B")
.Items.Add("C")
.Items.Add("D")
.Items.Add("E")
.Items.Add("F")
.Items.Add("G")
.Items.Add("H")
End With
End If

Dim objConn As SqlConnection
Dim strSql As String

strSql = "SELECT CompanyName, ContactName, ContactTitle, Phone "
_
& "FROM Customers"
objConn = New
SqlConnection(ConfigurationSettings.AppSettings("N orthwind"))

Dim sdaCust As New SqlDataAdapter(strSql, objConn)
Dim dstCust As New DataSet

sdaCust.Fill(dstCust, "Customers")

Dim dtbCust As DataTable = dstCust.Tables(0)
Dim dtvCust As New DataView(dtbCust)
dtvCust.RowFilter = "CompanyName LIKE '" &
ddlAlpha.SelectedValue.ToString & "%'"

dtvCust.Sort = "ContactName"
dtgCust.DataSource = dtvCust
dtgCust.DataBind()
End Sub
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 19 '05 #1
2 1347
Yes, here's an example for you:
http://msdn.microsoft.com/library/de...lesortable.asp

Or you could just use this free SuperDataGrid control which takes care all
of that tedious stuff automatically:
http://superexpert.com/default.aspx?id=427

--
I hope this helps,
Steve C. Orr, MCSD, MVP
http://Steve.Orr.net


"Patrick Olurotimi Ige" <pa*********@crazyjohns.com.au> wrote in message
news:uZ**************@tk2msftngp13.phx.gbl...
I have a DataView sorting below with DataGrid and Dataset.
When i try implementing default Paging with the DataGrid it gives error
when i want to SORT:-

Error:-
"CurrentPageIndex value. It must be >= 0 and < the PageCount. "

CAN ANYBODY FORWARD ME AN EXAMPLE WHERE I CAN SORT THE TABLE AND AT THE
SAME TIME PAGE!
Thanks!
I have the code below:-

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
'Put user code to initialize the page here
If Not IsPostBack Then
With ddlAlpha
.Items.Add("A")
.Items.Add("B")
.Items.Add("C")
.Items.Add("D")
.Items.Add("E")
.Items.Add("F")
.Items.Add("G")
.Items.Add("H")
End With
End If

Dim objConn As SqlConnection
Dim strSql As String

strSql = "SELECT CompanyName, ContactName, ContactTitle, Phone "
_
& "FROM Customers"
objConn = New
SqlConnection(ConfigurationSettings.AppSettings("N orthwind"))

Dim sdaCust As New SqlDataAdapter(strSql, objConn)
Dim dstCust As New DataSet

sdaCust.Fill(dstCust, "Customers")

Dim dtbCust As DataTable = dstCust.Tables(0)
Dim dtvCust As New DataView(dtbCust)
dtvCust.RowFilter = "CompanyName LIKE '" &
ddlAlpha.SelectedValue.ToString & "%'"

dtvCust.Sort = "ContactName"
dtgCust.DataSource = dtvCust
dtgCust.DataBind()
End Sub
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

Nov 19 '05 #2
Hi Steve,
Thanks for the LINKS.
Will have a look at that!
Patrick

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 19 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Al | last post by:
in order to implement sorting, paging in a datagrid, can I have the datasource of the datagrid a datareader or it must be a dataset then I create a dataview and make it a datasource of the...
9
by: jwedel_stolo | last post by:
Hi I'm creating a dataview "on the fly" in order to sort some data prior to writing out the information to a MS SQL table I have used two methods in order to determine the sort order of the...
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...
4
by: Bruce Pullum | last post by:
I have a datagrid that I am using a DataView with. All works great for the sorting of the columns. However, after I sort the column, and then try and select a data row to edit, the row selected...
1
by: Guoqi Zheng | last post by:
Sir, The default paging of datagrid is somehow use too much resource, so I am using Stored procedure for the paging. You can find my Stored procedure at the end of this message. It works...
0
by: Arjen | last post by:
Hi, Let's say we have a table with 2000 records. We are using the dataview control with paging and sorting. The dataview control always selects the full 2000 records and displays only 15...
5
by: enceladus311 | last post by:
I'm trying to find a way to keep from having to fill a DataView after every PostBack to a page. Basically, the design is that I have a DataView that I fill, which I then set as the DataSource to a...
0
by: webaccess | last post by:
Hi Friends ..!! I want to use datagrid/dataview control to data in tablular format,also I want to add paging and format the data of table column. Problem is data is coming from API Dom in as...
1
by: John A Grandy | last post by:
In regard to a GridView that must support searching, filtering, sorting, and paging ... There is a tradeoff in performing the sorting and paging in the database versus to creating a CLR sort...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

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.