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

Error When Sorting

I'm using the data grid with an ODBC database. I get an error when
clicking on the sorting. Either the page can't be displayed or I get the
error:
"The viewstate is invalid for this page and might be corrupted." Help
appreciated. Thanks.

<%@ Page Language="VB" Debug="true" %>
<%@ import Namespace="System.Data" %>
<%@ import Namespace="Microsoft.Data.ODBC" %>
<html>
<head>
</head>
<body>
<form runat="server">
<asp:DataGrid id="dgAR1" runat="server" AllowSorting="True"
OnSortCommand="SortColumn"/>

</form>
</body>
</html>

<script runat="server">
Public strViewString As String

Sub SetData()

Dim cn as OdbcConnection
cn = New OdbcConnection("dsn=SOTAMAS90AUTO;uid=sys;pwd=Rush ;")
Dim mystring As String = "Select Division, CustomerNumber,
CustomerName, AddressLine1 FROM AR1_CustomerMaster"

Dim ObjAdapter As New OdbcDataAdapter(mystring, cn)

Dim ObjDataSet As New DataSet()

ObjAdapter.Fill(objDataSet, "dtAR1")

Dim dtAR1 As DataTable = objDataSet.Tables("dtAR1")

Dim dvView As New DataView(dtAR1)
dvView.Sort = strViewString
dgAR1.DataSource = dvView
dgAR1.DataBind()
End Sub

Sub Page_Load(Source As Object, E As EventArgs)
If Not Page.IsPostBack Then
strViewString = "CustomerNumber"
SetData()
End If
End Sub

Sub SortColumn(Source As Object, E As DataGridSortCommandEventArgs)
If E.SortExpression = "Division" Then
strViewString = "Division, CustomerNumber"
Else
strViewString = E.SortExpression
End If
SetData()

End Sub

</script>

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

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

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...
6
by: David Cook | last post by:
The html file below gets intermittent errors 'error on page' ('number expected') when clicking on column-headings to sort. Yet, this same file works flawlessly in other browsers (i.e. Opera,...
2
by: Tim Pascoe | last post by:
I'm trying to implement a sorting routine for a string array. The sort routine is from http://ourworld.compuserve.com/homepages/attac-cg/acgsoft.htm (a great selection of routines in the 'Sequence...
0
by: kan | last post by:
I am sorry,I have poor english.. Two Class file is located below one namespace.. it is no error.. namespace Convert (namespace name) WinForm (first class name) ColumnSorter (second class...
2
by: awiklund | last post by:
Hi, I am sorting an arrayList using a custom comparer, but it sort the element in a uncommon fashion. Take a look at this code. using System; namespace ConsoleApplication8
6
by: miky | last post by:
Hi, I'm trying to get custom gridview paging working and I'm getting the following error: "ObjectDataSource 'ObjectDataSource1' could not find a non-generic method 'count' that has parameters:...
10
by: Dustan | last post by:
I'm hiding some of the details here, because I don't want to say what I'm actually doing. I have a special-purpose class with a __cmp__ method all set up and ready to go for sorting. Then I have...
1
by: kewldudehere | last post by:
Hi, I want to prevent the datagrid sorting on column header click events. i m handling mouse down events.When i have a breakpoint over my mousedown event and set my datagrid.allowsorting = false ...
4
by: rajtalent | last post by:
hi all, I want to sort the colum when clicks the columnheader using vb.net 2005 .But i receive the following error "Error 1 Overload resolution failed because no accessible 'New' accepts...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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: 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
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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,...

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.