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.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend4days leftRegister
Mata37 reputationPosted Nov 22, 2011, 4:07 AM EST
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();
}
Sam HobbsRank #108 · 20.5K reputationPosted Nov 22, 2011, 8:53 AM EST
Mata37 reputationPosted Nov 23, 2011, 3:07 AM EST
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();
}
}