To start I am using a MultiView control to step users through searching. The first page in the MultiView is just a search box with a button to preform the search.
The second page has the GridView, but I would like to keep the search box and button for the user to search again if they didn't find the user they were looking for.
When you search from page one and move to page 2 the GridView shows the correct results. But when it is on the second page with both the GridView and the search the GridView doesn't update. 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;
}
}