I have a datagrid that I am sorting then the user can select records to update. However after a sort and I try to select a record IT throws an error, like the data wasn't refreshed but I thought I was doing that in my code.
Below is the code for the sort.
Thanks for all your help in advance.
To go where no programmer has gone before.
Below is the code for the sort.
Thanks for all your help in advance.
Code:
Dim sort As String
Dim sortBy As Boolean
If IsNothing(Session("sortBy" + e.SortExpression)) Then
Session("sortBy" + e.SortExpression) = False
Else
sortBy = CType(Session("sortBy" + e.SortExpression), Boolean)
sortBy = Not sortBy
Session("sortBy" + e.SortExpression) = sortBy
End If
If sortBy Then
sort = e.SortExpression + " DESC"
Else
sort = e.SortExpression + " ASC"
End If
Dim SQl As String
Dim conAccess As New OleDb.OleDbConnection
Dim commAccess As New OleDb.OleDbCommand
Dim dsReason1 As New DataSet
conAccess.ConnectionString = Connection()
conAccess.Open()
commAccess.Connection = conAccess
SQl = "SELECT ID, MANAGER, SITE, INITIAL_DATE, CURRENTWEEK_DATE, EQUIPMENT_PEG, UTILIZATION, THRESHOLD, COMMENTS, REASON_CODE, EXPECTED_FIX_DATE, CURRENT_WEEK, RED_WEEK, ORANGE_WEEK, BLUE_WEEK, ROWID FROM SWDATA.TBLDIRECTORCOMMENTS WHERE (PEG_COLOR = 'R') ORDER BY " + sort
Dim AdpRed As New OleDb.OleDbDataAdapter(SQl, conAccess)
Dim Tbl As New DataTable
AdpRed.Fill(Tbl)
AdpRed.Dispose()
dgRed.DataSource = Tbl
dgRed.DataBind()
To go where no programmer has gone before.