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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top