473,320 Members | 1,814 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Problem with Hyperlink as value of If Statement

Long time listener first time poster

I have a link that I need to put into the if statement. Here is my hyperlink
<a href="notify.aspid=<%# DataBinder.Eval(Container.DataItem, "theid") %>">Test</a>

This works perfect if its on the page by itself and shows as just a regular hyperlink and goes to the notify page.

However when I go to insert it as a value of my if statement I get "Comma, ')', or a valid expression continuation expected."

This is my complete statement

<%# iif(DataBinder.Eval(Container.DataItem,"stockmessa ge")<>"Out of Stock","In Stock","<a href="notify.asp?id=<%# DataBinder.Eval(Container.DataItem, "theid") %>">Test</a>")%>

So basically this just lets them know if its in stock. If so it just says "In Stock". If it is out of stock I need to refer them to the notify page passing the itemid variable. Then they sign up for an alert when it becomes avaialable. I know Im missing something in my syntax...I just cannot figure this baby out!
any help would be appreciated.
Jack
Nov 29 '07 #1
6 1520
kenobewan
4,871 Expert 4TB
This should give some idea:
Condition on Container.DataItem in inline code
Nov 30 '07 #2
Plater
7,872 Expert 4TB
It looks like you are nesting <% calls, you might need to restructure it to not do that?
Expand|Select|Wrap|Line Numbers
  1. <%# iif(DataBinder.Eval(Container.DataItem,"stockmessage")<>"Out of Stock","In Stock","<a href="notify.asp?id=<%# DataBinder.Eval(Container.DataItem, "theid") %>">Test</a>")%>
  2.  
The <%# puts you into "code" mode and not in "html" mode so maybe try something like this:
Expand|Select|Wrap|Line Numbers
  1. <%# iif(DataBinder.Eval(Container.DataItem,"stockmessage")<>"Out of Stock","In Stock","<a href="notify.asp?id="+DataBinder.Eval(Container.DataItem, "theid").ToString()+">Test</a>")%>
  2.  
Nov 30 '07 #3
I looked at the mentioned link and id did not seem to help me out.
Here is the code I have so Far and I get a "Microsoft.VisualBasic Exception: Conversion from string " error.

<%# IIF(DataBinder.Eval(Container.DataItem,"stockmessa ge")<>"Out of Stock","In Stock","<a href=notify.asp?item='"+ Container.DataItem("theid")+"'>Out of Stock</a>")%>

Any help would be appreciated
Nov 30 '07 #4
Plater I tried your code and getting the error message "BC32017: Comma, ')', or a valid expression continuation expected."

I knows its gotta be somewhere in the syntax. Thats whats killing me!
I appreciate your help with this guys.
Nov 30 '07 #5
I got it!
<%# iif(DataBinder.Eval(Container.DataItem,"stockmessa ge")<>"Out of Stock","In Stock","<a href=notify.asp?id="+DataBinder.Eval(Container.Dat aItem, "theid").ToString()+">Test</a>")%>

Had to remove the first set of quotes in front of notify!
THANK YOU SOOOO MUCH for this.
take care and Ill be back to help out anyone I can.
Nov 30 '07 #6
Plater
7,872 Expert 4TB
I got it!
<%# iif(DataBinder.Eval(Container.DataItem,"stockmessa ge")<>"Out of Stock","In Stock","<a href=notify.asp?id="+DataBinder.Eval(Container.Dat aItem, "theid").ToString()+">Test</a>")%>

Had to remove the first set of quotes in front of notify!
THANK YOU SOOOO MUCH for this.
take care and Ill be back to help out anyone I can.
Ooops, I forgot to escape the ", it's a good idea to enclose your attribue's values (such as href) in quotes, I think it's part of the standards somewhere.
Expand|Select|Wrap|Line Numbers
  1. <%# iif(DataBinder.Eval(Container.DataItem,"stockmessage")<>"Out of Stock","In Stock","<a href=\"notify.asp?id="+DataBinder.Eval(Container.DataItem, "theid").ToString()+"\">Test</a>")%
  2.  
Nov 30 '07 #7

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: Andreas Meffert | last post by:
Hello, How can I change the Type of a field in a table from Memo to hyperlink? I import a table from Oracle to Access 2003. After that, the field type of some hyperlink-fields is "Memo". How...
0
by: compuglobalhypermeganetz0r | last post by:
I am having trouble getting an adapter to update my access database, it gives the error Syntax error in INSERT INTO statement. for Line 98: Adapter.Update(WineDS, "tblWines") Below is my...
3
by: Raja | last post by:
I have a datagrid, it has dropdown box as a column and i have one more column that has hyperlink. The NavigateURL for the hyperlink is to open a new window with a query stirng parameter as the...
6
by: epigram | last post by:
I'm using the DataGrid with AutoGenerateColumns set to false and choosing which columns I want in the grid by using the <Columns> attribute. What I want to do is to create a hyperlink out of one...
2
by: Fabrice | last post by:
Hello, First, thanks to felix for his answer. But :-( , I'm feeling newbie :! I' don't understand all the situation. The trouble : Always in the road whith my Datagrid and my ItemTemplate...
7
by: Bob Sanderson | last post by:
I have a php page which contains the code: echo "<tr>"; echo "<th>$JobNumber</th>"; echo "<td>$Description</td>"; echo "<td>$NSN</td>"; echo "<td>$Manufacturer</td>"; echo...
1
by: kkuniya | last post by:
Situation : - A form (method : POST, action : itself, onsubmit : alert 'Submit' ) - Got 2 submit button ( 'Save' , 'View') - Got navigation 1|2|3|4 What I want to do : - Once clicked on the...
3
by: Bren | last post by:
Hi All VS2005 Gridview control with vb I am populating a gridview of company staff. One of the columns is a hyperlink to a SMS texting facility I have so secrataries can text the managers...
3
by: keithb | last post by:
Using a GridView, I get a "Specified cast is not valid" error when binding the Visible propery of a hyperlink control to a DataTable text field. The error goes away if I replace the data binding...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.