Wrox Programmer Forums
Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 2.0 > ASP.NET 2.0 Basics
ASP.NET 2.0 Basics If you are new to ASP or ASP.NET programming with version 2.0, this is the forum to begin asking questions. Please also see the Visual Web Developer 2005 forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 2.0 Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
Old February 3rd, 2007, 10:56 PM
Authorized User
Join Date: Jan 2007
Posts: 54
Thanks: 0
Thanked 0 Times in 0 Posts
Default Filter using ObjectDataSource and Custom Objects

Dear All,

I am working on an application and had a situation where I wanted to filter the gridview based on user input (in a textbox). Its not difficult when working with SQLDataSource/DataSets or ObjectDataSource/DataSets etc. I am using Custom Entity classes which are returned by a Data Access class.

What I have done to solve this situation is to create a method in DAL called RetrieveAll(string sortedBy, string Criteria) and have used SelectMethod of ObjectDataSource to point to this method. The Select Parameter gets its value from a control (textbox). Initally the textbox is of course empty and DAL sends all the records. Once you enter something in textbox and say click 'Filter', the textbox value is passed to the DAL through the Select Parameter into the DAL and it gets only filtered records.

I am interested to know whether there is another, possibly better, solution to this issue of filtering ObjectDataSource while using Custom Objects. Please reply to this post if there are solutions for this problem that you know of.

Many thanks to Imar for his suggestions on this topic and specially on urging me to post this issue over the internet :)


Old June 26th, 2007, 06:36 AM
Registered User
Join Date: May 2006
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts

hi tahir,

have u found any other solution to this problem, i m facing same problem. I have multiple controls in filter criteria (like textbox, drop down list etc).

so can u guide me please...

Thanks in advance...

Old June 30th, 2007, 05:18 PM
Authorized User
Join Date: Jan 2007
Posts: 54
Thanks: 0
Thanked 0 Times in 0 Posts

I have stopped using ObjectDataSource! I found it easy to work without it as there are no design restrictions.

Old July 2nd, 2007, 04:11 PM
Friend of Wrox
Join Date: Jun 2007
Posts: 477
Thanks: 10
Thanked 19 Times in 18 Posts

How did you pull that off?

I've done some custom control building using Visual Basic Express, but am pretty new to trying to do the same thing in VWD.



Whatever you can do or dream you can, begin it. Boldness has genius, power and magic in it. Begin it now.
-Johann von Goethe

When Two Hearts Race... Both Win.
-Dove Chocolate Wrapper

Chroniclemaster1, Founder of www.EarthChronicle.com
A Growing History of our Planet, by our Planet, for our Planet.
Old July 5th, 2007, 04:26 AM
Registered User
Join Date: Jul 2007
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts

Hi tna55,

It looks like the project I'm working on at the moment has similar needs, i.e. several search criteria, a button to execute the search and display the results.

I've been going around and around in search of a way on how to do this, but some help would be greatly appreciated. Is there a way you could post or email me how you got it working?
I'm going the DAL route, but I'm curious how you did it...

-- Hans
Old July 17th, 2007, 01:07 PM
Imar's Avatar
Wrox Author
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts

Hi Hans,

Take a look here:


followed by parts two and three.

My book ASP.NET 2.0 Instant Results uses similar concepts. In the BugBase application chapter, I discuss how to build a Criteria object to do some advanced filtering at the database level.



Imar Spaanjaars
Everyone is unique, except for me.
Author of ASP.NET 2.0 Instant Results and Beginning Dreamweaver MX / MX 2004
Want to be my colleague? Then check out this post.

Similar Threads
Thread Thread Starter Forum Replies Last Post
How to use Dynamic Filter on ObjectDataSource onlinedev ASP.NET 2.0 Basics 0 December 5th, 2007 03:21 PM
ObjectDataSource and Smart Objects tna55 ASP.NET 2.0 Basics 0 February 22nd, 2007 07:04 AM
How count #objects of certain type, w/custom ctrl? three ASP.NET 2.0 Basics 1 May 6th, 2006 01:05 PM
Web Service Custom Objects Problem Amateur .NET Web Services 0 March 19th, 2006 11:52 AM
Objectdatasource, Custom Paging, and Filtering crimsondr ASP.NET 2.0 Professional 0 December 23rd, 2005 12:56 PM

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.