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

x
?
Solved

objectdatasource filterexpression using 'LEFT()' function?

Posted on 2009-02-12
4
Medium Priority
?
1,103 Views
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!

Nellster
0
Comment
Question by:nellster1000
  • 2
4 Comments
 
LVL 10

Accepted Solution

by:
JPJ78 earned 2000 total points
ID: 23621910
LEFT is not a valid command.
Here's  a list of them.
http://msdn.microsoft.com/en-us/library/system.data.datacolumn.expression(VS.80).aspx

Try:

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

Open in new window

0
 
LVL 11

Expert Comment

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

Expert Comment

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

Author Closing Comment

by:nellster1000
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.

Nellster
0

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