example below, so sometimes I would use both conditions and sometimes only one of them. Now when I don't use both, nothing gets filtered (I'm using this on gridview)
FilterExpression="NumberofPages= '{0}' and NumberofPeople= '{1}'" >
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
MataPosted Nov 23, 2011, 8:07 AM
Second problem is "solved" too:
If I have example 5 gridview columns and for that 5 textboxes which are my control parameters for filtering, for every combination of using those textboxes I must build custom FilterExpression and FilterParameters collection which has exact number of parameters which are textbox.text!="".
Than I must call everytime this routine (to build specific expression) on postback at page load event, because if I for example use update command at gridview, my filtering expression get's somehow overridden by my (default) Select Command in sql datasource and I don't preserve filtered gridview on postback, that is how I see it.
Because FilterParameters collection is preserved at postback I must clear it, to start a new clean process
In filter() routine FilterParameters collection is also built
protected void Page_Load(object sender, EventArgs e)
{
if (isPostBack)
{
SQLLocal.FilterParameters.Clear();
SQLLocal.FilterExpression = filter();
SQLLocal.DataBind();
}
}
Sam HobbsPosted Nov 22, 2011, 1:53 PM
MataPosted Nov 22, 2011, 9:07 AM
Now I programmaticly builded filter, so everytime (based on value of textbox fields) I define exact number of parameters which I will really use. This works fine but only on first postback I get correct results for all combinations of fields(textboxes). When I click second time, my filter doesn't show results as I would expect . Why is that?
protected void Page_Load(object sender, EventArgs e)
{
SQLLocal.FilterExpression = filter();
SQLLocal.DataBind();
}