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 December 5th, 2007, 03:21 PM
Registered User
 
Join Date: Dec 2007
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default How to use Dynamic Filter on ObjectDataSource

Hi,
I also have a similar kind of requirements, if possible please let me know how can do this...

Issue Details: Please let me know, in case my question is not clear.

Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim strFieldName As String

        strFieldName = DropDownList1.SelectedValue
        iStrFilter = strFieldName & " Like '" & txtSearch.Text.ToString() & "%'"
        HiddenField1.Value = iStrFilter
        If iStrFilter <> "" Then
            ObjectDataSource1.FilterExpression = iStrFilter '"FirstName Like '" & iStrFilter & "%'"
        Else
            ObjectDataSource1.FilterExpression = ""
        End If
        GridView1.DataBind()
    End Sub

I have 2 external textboxes with the name txtSeaarchField and txtSearchVal
and below I have a gridview

Basically, this is a enhanced search where user will choose the field name and fieldvalue and then perform search. So far, I am unable to find the best solution ..I can prepare the filterexpression string and then put in the filter expression but the point is how will I come to know that what is the type of the field ..means say ProductId is integer and what is the way to know that product id is of type int and then prepare the filter expression string accordingly. I don't want to keep this information in the array / arraylist or collection...is there anyway that I can come to know about the type of the field at runtime from gridview or objectdatasource or sqldatasource. Please reply.
Regards,
VD









Similar Threads
Thread Thread Starter Forum Replies Last Post
ObjectDataSource in UserControl Colonel Angus .NET Framework 2.0 0 April 3rd, 2008 10:14 AM
Filter using ObjectDataSource and Custom Objects tna55 ASP.NET 2.0 Basics 5 July 17th, 2007 01:07 PM
CH5 ObjectDataSource nabeelalkaff BOOK: ASP.NET 2.0 Website Programming Problem Design Solution ISBN: 978-0-7645-8464-0 0 March 8th, 2007 01:19 PM
Dynamic Pivot Table Filter?? tready Excel VBA 1 February 21st, 2006 01:27 AM
Dynamic Filter Form, need tip jbash111 Access 3 January 24th, 2005 12:54 PM





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