shanekahkola
Member
- Joined
- Apr 3, 2006
- Messages
- 5
I have searched the forums but, I cant seem to find anything that speaks to this:
I have a GridView in my web app that retrieves data via a SQLDataSource. When the page opens, it automatically displays all data found in a particular table. I have three problems that I suspect are all related:
Problem #1:
I have a vb text box and button that allows the user to enter a phrase and click search. So far, that part is working pretty good. Below is the code that is executed when they click search:
I get the desired effect where the grids data changes to include only what matches the search text. However, when someone clicks on the header to sort the results, it goes back to the original query which is as follows:
Problem #2:
If the search results return more than one page, clicking on the page you want to go to also reverts back to the original query.
Problem #3:
I have a button that allows the user to reset grid to the original query, or clear the query results. The code is as follows:
The above code sort of works. It causes the grid to return to its original state but, the paging on the bottom only matches the previous search query.
What else do I need to post to give someone a good idea of what I am trying to do?
Any help would be appreciated. Thank you.
I have a GridView in my web app that retrieves data via a SQLDataSource. When the page opens, it automatically displays all data found in a particular table. I have three problems that I suspect are all related:
Problem #1:
I have a vb text box and button that allows the user to enter a phrase and click search. So far, that part is working pretty good. Below is the code that is executed when they click search:
Code:
Protected Sub btnSearch_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnSearch.Click
Me.sqlArchive.SelectCommand = "SELECT * FROM ARCHIVEHOLDINGS WHERE CONTAINS(*," & Me.txSearch.Text & ") ORDER BY TITLE ASC"
End Sub
I get the desired effect where the grids data changes to include only what matches the search text. However, when someone clicks on the header to sort the results, it goes back to the original query which is as follows:
Code:
Me.sqlArchive.SelectCommand="SELECT * FORM ARCHIVEHOLDINGS ORDER BY TITLE ASC"
Problem #2:
If the search results return more than one page, clicking on the page you want to go to also reverts back to the original query.
Problem #3:
I have a button that allows the user to reset grid to the original query, or clear the query results. The code is as follows:
Code:
Protected Sub btReset_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btReset.Click
Dim sSortDir As String
If Me.gvArchives.SortExpression <> "" Then
If gvArchives.SortDirection = SortDirection.Ascending Then
sSortDir = "ASC"
Else
sSortDir = "DESC"
End If
Me.sqlArchive.SelectCommand = "SELECT * FROM ARCHIVEHOLDINGS ORDER BY " & Me.gvArchives.SortExpression & " " & sSortDir
Me.gvArchives.DataSourceID = "sqlArchive"
Me.gvArchives.DataBind()
Else
Me.sqlArchive.SelectCommand = "SELECT * FROM ARCHIVEHOLDINGS ORDER BY Title ASC"
Me.gvArchives.DataSourceID = "sqlArchive"
Me.gvArchives.DataBind()
End If
Me.txSearch.Text = ""
End Sub
What else do I need to post to give someone a good idea of what I am trying to do?
Any help would be appreciated. Thank you.
Last edited by a moderator: