By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,361 Members | 2,183 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,361 IT Pros & Developers. It's quick & easy.

set visibility of label in datagrid IF text string present

P: n/a
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.

Apr 10 '06 #1
Share this Question
Share on Google+
3 Replies


P: n/a
Are you able to extract the string from the cell?
Look into Regular Expressions (Regex)

Apr 10 '06 #2

P: n/a
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....
<fo**********@gmail.com> wrote in message
news:11**********************@z34g2000cwc.googlegr oups.com...
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.

Apr 10 '06 #3

P: n/a
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.

Apr 10 '06 #4

This discussion thread is closed

Replies have been disabled for this discussion.