Datagrid: how-to dynamically change WHERE conditions

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I'm trying to dynamicaly change Where conditions in a Datagrid without success.
The aspx form has some input fields, used to build the search, plus a final
SEARCH button. In the click event I build the SQL Select stmt and do the
following:
Me.DataSourceSearch.SelectCommand = "SELECT ... WHERE ...."
Me.gridResult.DataBind()

The datagrid has been designed with a generic SELECT command like "SELECT *
FROM Mytable", that in my supposing should be overwritten by the
..SelectCommand stmt.

Problem: Clickng the Search button I get a correct first page Datagrid, but
paging I then get data without any Where condition set.

I've tryed many other ways without success. Where is my fault?

Many thanks.
 
Try writing the statements you write in the Search button click in a
function (e.g. Bind) and then call it from Search button. And also in the
paging event instead call the new Bind method.

Regards,
Rohit
 
It worked.
Thanks
--
bruno


Rohit Kukreti said:
Try writing the statements you write in the Search button click in a
function (e.g. Bind) and then call it from Search button. And also in the
paging event instead call the new Bind method.

Regards,
Rohit
 
Back
Top