Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Wanet Telecoms Ltd on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

comparing strings to patterns

Status
Not open for further replies.

JaneB19

Technical User
Jun 27, 2002
110
GB
Hi,

I'm having some difficulty with the following. I don't think it should be very complicated, it's just how to go about it!

What I am trying to do is compare a string to a pattern, if the string is like the pattern then copy the string from the dataGrid or dataList into, I was thinking another dataGrid or list, but I'm changing my mind to having a Response.Write().

I know that you can do IF string LIKE pattern THEN ...
I have the coding for getting the string in a dataGrid, where the dataGrid has been filled by an SQL query to the database.

AdvancedSolutions1 is the original dataGrid
txtBox is the textbox that the user enters the pattern into

Dim itm As DataGridItem
Dim cel As TableCell
Dim cellText As String

cellText = cel.Text

For Each itm In AdvancedSolutions1.Items
For Each cel In itm.Cells
If cellText LIKE txtBox Then
.
.
.
End If
Next
Next


I've tried things like AdvancedSolutions2.DataBind() where AdvancedSolutions2 is the name of the dataGrid that I'd like the text passed into.

I've also tried

Dim itm As DataListItem
Dim dlCell As TableCell
Dim cellText As String
Dim List As String

cellText = dlCell.Text

For Each dlCell In DataList1.Items
If cellText Like txtBox.Text Then
dlCell.Text.Copy(List)
End If
Next

Response.Write(List)


but the page wouldn't display with this one.

If anybody can help, or point me in the right direction it would be greatly appreciated, as I've been stuck with this problem for the last couple of weeks!

Thanks in advance
 
Jane: haven't tried your code but you might have to qualify further your text box, e.g., instead of:

If cellText Like txtBox.Text Then

..perhaps something like...

If cellText Like "'%" & txtBox.Text & "%'" Then

..along those lines, however, if your pattern in not string dependent but format dependent, or length dependent only, you will have to try another approach..just a thought.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top