To get started, I use the MultiView control to navigate users through the search. The first page in MultiView is just a search box with a button for a preliminary search.
The second page has a GridView, but I would like to save the search box and a button to search for the user again if they did not find the user they were looking for.
When you search from page 1 and go to page 2, the GridView shows the correct results. But when it is on the second page with GridView and search, GridView is not updated. Below is the code I'm using.
//GridView = SearchResults //SqlDataSource = AddPlayerDataSource //MultiView = PlayerSearchView protected void PlayerSearch_Click(object sender, ImageClickEventArgs e) { string userId = User.Identity.Name.ToString(); if (SearchText.Text != "" && !userId.Equals("")) { GridView SearchResults = (GridView)PlayerSearchView.FindControl("SearchResults"); string SqlSelect = "SELECT [id], [username] FROM [users] WHERE [username] LIKE '%" + SearchText.Text + "%'"; AddPlayerDataSource.SelectCommand = SqlSelect; SearchResults.DataBind(); if (PlayerSearchView.ActiveViewIndex != 1) PlayerSearchView.ActiveViewIndex = 1; } }
source share