473,776 Members | 1,606 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Problem with Hyperlink as value of If Statement

4 New Member
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.as pid=<%# DataBinder.Eval (Container.Data Item, "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,"stock message")<>"Out of Stock","In Stock","<a href="notify.as p?id=<%# DataBinder.Eval (Container.Data Item, "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 1541
kenobewan
4,871 Recognized Expert Specialist
This should give some idea:
Condition on Container.DataI tem in inline code
Nov 30 '07 #2
Plater
7,872 Recognized Expert Expert
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
wonijack
4 New Member
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.Visu alBasic Exception: Conversion from string " error.

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

Any help would be appreciated
Nov 30 '07 #4
wonijack
4 New Member
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
wonijack
4 New Member
I got it!
<%# iif(DataBinder. Eval(Container. DataItem,"stock message")<>"Out of Stock","In Stock","<a href=notify.asp ?id="+DataBinde r.Eval(Containe r.DataItem, "theid").ToStri ng()+">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 Recognized Expert Expert
I got it!
<%# iif(DataBinder. Eval(Container. DataItem,"stock message")<>"Out of Stock","In Stock","<a href=notify.asp ?id="+DataBinde r.Eval(Containe r.DataItem, "theid").ToStri ng()+">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
7534
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 can I schwitch back to Hyperlink via VBA because its boring doing it manually often (I import the table each week for doing updates). When I do it manually the hyperlink works well. Thanks in advance.
0
1769
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 code: <%@ Control Explicit="True" Language="VB" Debug="True" %> <%@ Import Namespace="System.Data" %> <%@ Import Namespace="System.Data.OleDb" %>
3
1905
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 selected value of the drop down... here is how it looks like <asp:datagrid....> .... <asp:TemplateColumn> <ItemTemplate>
6
2942
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 of the columns that I am displaying, but in order to build this link, I need a value that is in my SELECT clause, but is not being displayed via a BoundColumn. Say I have a query: SELECT ID, Name FROM Companies Here, ID is the PK. I am only...
2
1841
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 with a Control HyperLink. I would like to fix many properties of this Control Hyperlink in the Code
7
11721
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 "<td>$PartNumber</td>"; echo "</tr>";
1
2581
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 navigation page, it will save the page without need to click on 'Save' button. Currently, if i manually clicked on the 'Save' button; it will save the page.
3
4173
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 etc. i.e Secratary loads the page on the intranet, finds the manager they want to contact, clicks on the "SMS" hyperlink and is taken to the SMS page to fill out the message and send it to the manager.
3
3699
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 statement with "true" or "false". This code causes the error: <asp:HyperLink ID="HyperLink1" runat="server" NavigateUrl='<%# Eval("c2Hyperlink1Link") %>' Target="_blank"
0
9628
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9464
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10292
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10061
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8954
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7471
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6722
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5368
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
3
2860
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.