SQLDataSource FilterExpression question

Discussion in 'ASP .Net' started by fniles, Mar 25, 2009.

  1. fniles

    fniles Guest

    I am using VS 2005.
    In my ASP.NET page I have a combo box that lists the columns I can search
    in, a Search text box (where you can input your search word) and a Search
    button.
    The result of the search appears in a gridview.
    I have bound the gridview to a SQLDataSource.
    When the Search button is hit, I set the filterExpression for the
    SQLDataSource to something like so:
    filterExpression = string.Format("[{0}] LIKE '%{1}%'",
    cboSearch.SelectedValue, txtSearch.Text)
    SqlDataSource1.FilterExpression = filterExpression

    If I select "Module" from the combo box cboSearch, I would like to filter
    the SQLdatasource with something like
    where MODULE1 like '%' & {txtSearch.Text} '%' or MODULE2 like '%' &
    {txtSearch.Text} '%'
    How can I set the filterExpression to do the above ?

    Thank you.
    fniles, Mar 25, 2009
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Replies:
    1
    Views:
    7,406
    Markus
    Aug 25, 2005
  2. Henry Habermacher [MVP Access]

    GridView - Changing FilterExpression of SQLDataSource and Paging

    Henry Habermacher [MVP Access], Jan 20, 2006, in forum: ASP .Net
    Replies:
    2
    Views:
    10,975
    kmarchiony
    Jul 31, 2007
  3. Replies:
    0
    Views:
    3,060
  4. fniles
    Replies:
    0
    Views:
    454
    fniles
    Mar 29, 2009
  5. fniles
    Replies:
    1
    Views:
    805
    Alexey Smirnov
    Mar 30, 2009
Loading...

Share This Page