Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Sorting a Datagrid and then selecting a record to update

Status
Not open for further replies.

dbsquared

Programmer
Nov 7, 2002
175
US
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.

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.
 
On a line I get the error object require in the HTML debugger.

When I look at that line of code is the old placement of the item before it was sorted.


To go where no programmer has gone before.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top