I am trying to sort a query in an asp.net page.
the page contains a grid (peopleid, contactname, contactcompany), populated by a query against the database, the grid is sortable by lastname, company.(clicking the header)
I create a button on the page that will refresh an other query that is filtered by the contactid selected in my grid (all the selected contactid separated by a comma are stored in a label)
see code 1
The second query looks like (see code 2)
I would like the system to order the second query in the same order as they are selected in the grid. So if by example, I order my grid by company and then select each people seprately, the second query result will keep the order of selection.
By the way, the system actually store each peopleid in the lblpeopleidtxt correctly, but fail to keep this order in the second query.
Thanks for your help
Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs)
' StringBuilder object
Dim str As New StringBuilder()
Dim first As Boolean = True
For i As Integer = 0 To GridView1.Rows.Count - 1
' Select the checkboxes from the GridView control
Dim row As GridViewRow = GridView1.Rows(i)
Dim isChecked As Boolean = DirectCast(row.FindControl("chkSelect"), CheckBox).Checked
If isChecked Then
If first Then
first = False
' Column 2 is the name column
' prints out the result
lblpeopleid.Text = str.ToString
code 2: the query
SELECT PEOPLE.PEOPLEID, PEOPLE.FIRSTNAME,... from people where (',' || TO_CHAR(:PEOPLEID) || ',' LIKE '%,' || TO_CHAR(PEOPLE.PEOPLEID) || ',%')