views:

249

answers:

3

I have a custom ASPX search page for a CRM 4.0 solution I am working on. I want to be able to clear out the asp.net datagrid I have on the search page. Right now if a person does a search it returns the results in the datagrid but if they do another search and there are no results for the new search the old search results are still in the datagrid.

+3  A: 

Not sure how you have implemented the search. But I think you simply have to make sure that you are binding the grid to the result of the search (in both cases).

E.g. if the search returns an empty result (list/datareader/dataset), just bind the grid to it and it should not display any records:

grid.DataSource = GetSearchResults(); // may return an empty search result
grid.Databind();
M4N
+1  A: 

You should rebind the datagrid on every postback. Also set the EmptyDataText attribute with the text you want to display when there are no search results from query.

Michael Kniskern
There is also EmptyDataTemplate, if more control is required.
RichardOD
A: 

Datagrid.DataSource = New DataView;

Datagrid.DataBind()

Som