[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now


objectdatasource filterexpression using 'LEFT()' function?

Posted on 2009-02-12
Medium Priority
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
  • 2
LVL 10

Accepted Solution

JPJ78 earned 2000 total points
ID: 23621910
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

by:Anurag Agarwal
ID: 23622011
use like this
odsAdminSubmissionAll.FilterExpression = "SubFirstName LIKE '%" & strLetter
It Should Work
LVL 11

Expert Comment

by:Anurag Agarwal
ID: 23622030
use like this
odsAdminSubmissionAll.FilterExpression = "SubFirstName LIKE strLetter & "%"
It Should Work

Author Closing Comment

ID: 31546041
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.


Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Sometimes in DotNetNuke module development you want to swap controls within the same module definition.  In doing this DNN (somewhat annoyingly) swaps the Skin and Container definitions to the default admin selections.  To get around this you need t…
In .NET 2.0, Microsoft introduced the Web Site.  This was the default way to create a web Project in Visual Studio 2005.  In Visual Studio 2008, the Web Application has been restored as the default web Project in Visual Studio/.NET 3.x The Web Si…
Integration Management Part 2
Is your data getting by on basic protection measures? In today’s climate of debilitating malware and ransomware—like WannaCry—that may not be enough. You need to establish more than basics, like a recovery plan that protects both data and endpoints.…

872 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