DataView Sorting with Paging Question

  • Thread starter Patrick Olurotimi Ige
  • Start date
P

Patrick Olurotimi Ige

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("Northwind"))

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
 
P

Patrick Olurotimi Ige

Hi Steve,
Thanks for the LINKS.
Will have a look at that!
Patrick
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top