This is a migrated thread and some comments may be shown as answers.

Filtering on a list of values

1 Answer 157 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Craigy
Top achievements
Rank 1
Craigy asked on 22 Mar 2012, 04:54 PM
Hi all!

I'm currently prototyping a 'Telerik' version of a suite of tools I created for the administration of our application's database.  It's ticking all the boxes as far as interactivity on the frontend goes and I want to show that it's a viable option for replacing some of our older vanilla ASP.NET 2.0 tools.

One of the tools in question allows a user to copy a list of values (in some instances GUIDs, others just simple integers) in to a textbox (1 value per line) and send that to the Datasource for filtering on.  This is then displayed in a vanilla ASP.NET GridView.

For example, a user may fill in the filter box like this:

IDs
====
1156
785636
72889

...and the system will return entities with those IDs.

I run the contents of those various textboxes through a splitter and sanitizer (essentially a set of RegExs to ensure there's no errors or injection attempts) before submission, but the only way I've been able to get that list to the DB is by using a String.Replace on the SELECT code in the Datasource before it refreshes, which puts the list of values into an IN clause.  I hate this because it feels like a hack and stops me using SPROCs for my Datasource, but it does work.

I've read in one Google result that a nice way of doing this is to somehow convert the Textbox contents into a CSV or XML file and submit it that way, but it doesn't seem to help with the overall complexity of the code and it doesn't make use of anything that Telerik provides over and above vanilla ASP.NET.

Does anybody know how I might go about doing this in a more 'proper' fashion using any functionality that Telerik provides?  Am I best off trying to perform the same hack, or have any of you managed to make such a filter in a smoother way?

1 Answer, 1 is accepted

Sort by
0
Tsvetina
Telerik team
answered on 28 Mar 2012, 08:06 AM
Hello Craigy,

Have you considered using the RadFilter control, which would build a ready-to-use filter expression based on the user's interaction with its UI.
You can either directly assign the ID of a datasource control as DataSourceControlID of the filter or use the query providers offered by the control to build different syntax expressions and use them in your queries to the DB.

Regards,
Tsvetina
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
Tags
Grid
Asked by
Craigy
Top achievements
Rank 1
Answers by
Tsvetina
Telerik team
Share this question
or