S
Steve Bishop
I get an error when trying to click on the sorting links in the header.
Would anyone know why I would receive this error? Unfortunately, I need
to work with ODBC connections. Help appreciated. Error is: "The
viewstate is invalid for this page and might be corrupted."
<%@ Page Language="VB" Debug="true" %>
<%@ import Namespace="System.Data" %>
<%@ import Namespace="Microsoft.Data.ODBC" %>
<html>
<head>
</head>
<body>
<form runat="server">
<aspataGrid 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>
Would anyone know why I would receive this error? Unfortunately, I need
to work with ODBC connections. Help appreciated. Error is: "The
viewstate is invalid for this page and might be corrupted."
<%@ Page Language="VB" Debug="true" %>
<%@ import Namespace="System.Data" %>
<%@ import Namespace="Microsoft.Data.ODBC" %>
<html>
<head>
</head>
<body>
<form runat="server">
<aspataGrid 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>