This topic is locked

How to filter data on first load

1/6/2016 5:32:53 PM
ASPRunner.NET Tips and tricks
admin

Q: I'd like to filter my data initially only showing customers where status is 'active'. This should not affect all subsequent searches.
A: There are several ways to achieve that. Probably the easiest way is to add the following to 'After table initialized' event of the table in question:

if (System.Web.HttpContext.Current.Request.QueryString.Count==0)

query.addWhere("status='active'");
M
Mack88DevClub member 2/1/2016

Thanks to jadach for pointing out this post <img src='https://asprunner.com/forums/file.php?topicimage=1&fieldname=reply&id=78690&image=1&table=forumreplies' class='bbc_emoticon' alt=':)' />
Seems to do the job. However, there also seems to be a catch ... if I then sort by clicking the column header, the filter is lost. i.e. all data are returned, not just the filtered records.
Is there a way to keep the filter in place after rendering the initial data?
Thanks in advance.
PS At the risk of stretching this post too far, I would like the user to be able to set the date range, rather than making this a design time parameter selection. Should I start a new topic?

admin 2/2/2016

This subforum is not for questions really. Feel free to start a new topic in the main forum.