objectdatasource filterexpression using 'LEFT()' function?

Posted on 2009-02-12
Last Modified: 2012-05-06
Hi all. I am working on a ASP NET 2.0 (vb net) site. I have created an objectdata source that is bound to a gridview. I want to filter the gridview based on matching the first letter of the firstname column with an inputted value.

I have previously matched letters using the following expression:

odsAdminSubmissionAll.FilterExpression = "SubFirstName LIKE '%" & txtSearch.Text & "%'"

In order to try and match the first letter I did the following:

        odsAdminSubmissionAll.FilterExpression = "LEFT(SubFirstName, 1) = '" & strLetter & "'"

The error I got was:
"Exception Details: System.Data.EvaluateException: The expression contains undefined function call LEFT()."

Anyone point me in the right direction?

many thanks in advance!

Question by:nellster1000
    LVL 10

    Accepted Solution

    LEFT is not a valid command.
    Here's  a list of them.


    odsAdminSubmissionAll.FilterExpression = "SUBSTRING(SubFirstName, 0, 1) = '" & strLetter & "'"

    Open in new window

    LVL 11

    Expert Comment

    use like this
    odsAdminSubmissionAll.FilterExpression = "SubFirstName LIKE '%" & strLetter
    It Should Work
    LVL 11

    Expert Comment

    use like this
    odsAdminSubmissionAll.FilterExpression = "SubFirstName LIKE strLetter & "%"
    It Should Work

    Author Closing Comment

    Thanks for the quick responses guys.

    JPJ78, had to modify slightly to SUBSTRING(SubFirstName, 1, 1) as strating position is 1 aparantly and not 0 but you showed me the way!

    anuragal, tried both your suggestions but neither worked for me but thank you for helping.


    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    What Should I Do With This Threat Intelligence?

    Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

    Lots of people ask this question on how to extend the “MembershipProvider” to make use of custom authentication like using existing database or make use of some other way of authentication. Many blogs show you how to extend the membership provider c…
    International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
    Migrating to Microsoft Office 365 is becoming increasingly popular for organizations both large and small. If you have made the leap to Microsoft’s cloud platform, you know that you will need to create a corporate email signature for your Office 365…
    In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

    758 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    8 Experts available now in Live!

    Get 1:1 Help Now