set visibility of label in datagrid IF text string present

F

footballhead

Hello-

I have page on my site that displays the results of a product search in
a datagrid.

There is a text field that has a full description of the product named
FullInfo. I have placed some keywords in this description that denote
certain things about the product such as SALE, CLOSEOUT, FREE_SHIPPING,
etc.

I have labels in the datagrid template for each condition above (SALE,
CLOSEOUT, etc). These lables are all set to Visible="False". I'd like
to make these visible IF the keyword appears in the FullInfo text
field.

I am stuck on figuring out how to read through the text in the FullInfo
field for the keywords. I have tried using a sub-routine with an IF
statement and IndexOf to determine if the keyword is present but that
did not work.

Any help is appreciated, thanks!

Rick D.
 
K

KBuser

Are you able to extract the string from the cell?


Look into Regular Expressions (Regex)
 
J

Jeff Dillon

IndexOf would certainly work.

dim i as integer

Dim strTest As String = "we have a SALE on foxes"

i = strTest.IndexOf("SALE")

if i > 0 then....
 
F

footballhead

Jeff-

I've got that exact code working on other pages where the field in
question has been placed into a Label.

On this page that I am working on, the text that I need to search
through is in the datagrid. It's being called like this:
<%# DataBinder.Eval(Container.DataItem, "FullInfo") %>

I succesfully added a new Label named lblFullInfo INSIDE that datagrid
template and set the Text property to = <%#
DataBinder.Eval(Container.DataItem, "FullInfo") %>. This works and
shows up when I test the page.

However, when I add my script, I get the error:
Name 'lblFullInfo' is not declared.

Here is my script:

<script runat="server">
dim isFreebie as String = lblFullInfo.text
if isFreebie.IndexOf( "freebie" ) > 0 Then
lblFullInfo.visible = True
End if
</script>

NOTE: I only have access to the aspx page, I cannot get to the
code-behind.

Thanks!

Rick D.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top