Wrox Programmer Forums
Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 1.0 and 1.1 > ASP.NET 1.0 and 1.1 Basics
|
ASP.NET 1.0 and 1.1 Basics ASP.NET discussion for users new to coding in ASP.NET 1.0 or 1.1. NOT for the older "classic" ASP 3 or the newer ASP.NET 2.0.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 1.0 and 1.1 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 17th, 2005, 07:26 PM
Authorized User
 
Join Date: Dec 2005
Posts: 19
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to raybristol
Default about how to use dataview to search, thanks!

i want to use dataview's filter for searching, then bind it with a datagrid for showing the results, now i got a textfield for user typing whatever they want to search, so far I¡¡only know how to use Like for search, for example my code is like:


 DataView1.RowFilter = "Title LIKE ' %" + textbox.text.trim.tostring() + "%'"

this works fine, however, it only can search from the begining of a record, for example, if I have a record with title 'Today is sunny!', then user will be able to get this title by typing in 'Today' or even just 'T' then all titles start with 'Today' or 'T' will be showed. however if user type 'is sunny' then it can't be shown. my question is how to make that happen? I hope this make sense, thanks everyone, I wish you all have a happen Christmas!

 
Old December 17th, 2005, 07:32 PM
Authorized User
 
Join Date: Dec 2005
Posts: 19
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to raybristol
Default

sorry my code was:
DataView1.RowFilter = "Title LIKE ' " + textbox.text.trim.tostring() + "%'"

i can't put % right after Like, it won't work.

 
Old December 18th, 2005, 01:52 AM
Friend of Wrox
 
Join Date: Nov 2003
Posts: 1,348
Thanks: 0
Thanked 5 Times in 5 Posts
Default

Try:
DataView1.RowFilter = "Title LIKE " + "'%" + TextBox.Text.Trim.Tostring + "%'"

Jim

 
Old December 18th, 2005, 08:47 AM
Authorized User
 
Join Date: Dec 2005
Posts: 19
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to raybristol
Default

yes, it works, thanks so much!!!!!!thxxxxx

 
Old December 18th, 2005, 04:57 PM
Friend of Wrox
 
Join Date: Nov 2003
Posts: 1,348
Thanks: 0
Thanked 5 Times in 5 Posts
Default

glad to help...

Jim

 
Old April 25th, 2008, 06:02 AM
Registered User
 
Join Date: Sep 2007
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Yes it works, but only until the user types apostrophe ('), percent (%), asterisk (*) or square bracket ([). In this case it fails. You should escape the value using EscapeLikeValue method. More informations, how to escape values, see article DataView.RowFilter Expression Syntax.





Similar Threads
Thread Thread Starter Forum Replies Last Post
dataview Yasho VB.NET 2002/2003 Basics 1 May 28th, 2007 03:40 AM
DataView Not Sorting pbyrum C# 3 December 27th, 2004 06:30 PM
making changes to dataview bluelaser VS.NET 2002/2003 0 September 20th, 2004 10:15 PM
Help me with Dataview object. aadz5 ASP.NET 1.0 and 1.1 Basics 2 November 20th, 2003 07:52 AM
DataView vivi C# 4 November 10th, 2003 01:15 AM





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