Question

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.

Was it helpful?

Solution

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();

OTHER TIPS

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top