473,653 Members | 3,015 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

<a href> & <asp:Hyperlin k>

Consider the following code:

<script runat="server">
Sub Page_Load(obj As Object, ea As EventArgs)
Dim sqlReader As SqlDataReader

sqlReader = 'calling a function that returns SqlDataReader

dlCart.DataSour ce = sqlReader
dlCart.DataBind
End Sub
</script>
<form runat="server">
<asp:DataList ID="dlCart" runat="server">
<HeaderTemplate >
<table>
<tr>
........
........
........
</tr>
</HeaderTemplate>
<ItemTemplate >
<tr>
<td><%# Container.DataI tem("ProdID") %></td>
<td><%# Container.DataI tem("ProductNam e") %></td>
<td><%# Container.DataI tem("Price") %></td>
<td><a href='RemoveIte m.aspx?ProdID=< %# Container.DataI tem("ProdID")
%>'>Remove</a></td>
</tr>
</ItemTemplate>
......
</asp:DataList>
</form>

Assume that the DataList displays 3 products to a user. The ProdIDs of
the 3 products are 10, 20 & 30 respectively.

When the user clicks the product whose ProdID is 10, as expected, he is
taken to RemoveItem.aspx with the querystring ProdID=10 appended to it
i.e. the user is taken to

http://myserver/RemoveItem.aspx?ProdID=10

But instead of using <a href...for rendering the 'Remove' link, if I
use <asp:Hyperlin k>

<td><asp:Hyperl ink ID="lnk" NavigateUrl='Re moveItem.aspx?P rodID=<%#
Container.DataI tem("ProdID") %>' Text="Remove" runat="server"/></td>

then <%# Container.DataI tem("ProdID") %doesn't get assigned to the
appropriate ProdID. Rather, the URL of link literally remains as what
is coded above (using <asp:Hyperlink. .>). In other words, irrespective
of whichever 'Remove' link a user clicks, he is taken to

http://myserver/RemoveItem.aspx ?ProdID=<%#%20C ontainer.DataIt em("ProdID")%20 %>

How do I use <%# Container.DataI tem("ProdID") %in the NavigateUrl
property of <asp:Hyperlinki n order to assign the corresponding
database ProdID value to the querystring ProdID so that, for e.g. if
the user clicks the 'Remove' link corresponding to the product whose
ProdID is 10, he is taken to

http://myserver/RemoveItem.aspx?ProdID=10

Oct 1 '06 #1
1 5730
http://weblogs.asp.net/rajbk/archive...20/188868.aspx
<rn**@rediffmai l.comwrote in message news:11******** **************@ i3g2000cwc.goog legroups.com...
Consider the following code:

<script runat="server">
Sub Page_Load(obj As Object, ea As EventArgs)
Dim sqlReader As SqlDataReader

sqlReader = 'calling a function that returns SqlDataReader

dlCart.DataSour ce = sqlReader
dlCart.DataBind
End Sub
</script>
<form runat="server">
<asp:DataList ID="dlCart" runat="server">
<HeaderTemplate >
<table>
<tr>
.......
.......
.......
</tr>
</HeaderTemplate>
<ItemTemplate >
<tr>
<td><%# Container.DataI tem("ProdID") %></td>
<td><%# Container.DataI tem("ProductNam e") %></td>
<td><%# Container.DataI tem("Price") %></td>
<td><a href='RemoveIte m.aspx?ProdID=< %# Container.DataI tem("ProdID")
%>'>Remove</a></td>
</tr>
</ItemTemplate>
.....
</asp:DataList>
</form>

Assume that the DataList displays 3 products to a user. The ProdIDs of
the 3 products are 10, 20 & 30 respectively.

When the user clicks the product whose ProdID is 10, as expected, he is
taken to RemoveItem.aspx with the querystring ProdID=10 appended to it
i.e. the user is taken to

http://myserver/RemoveItem.aspx?ProdID=10

But instead of using <a href...for rendering the 'Remove' link, if I
use <asp:Hyperlin k>

<td><asp:Hyperl ink ID="lnk" NavigateUrl='Re moveItem.aspx?P rodID=<%#
Container.DataI tem("ProdID") %>' Text="Remove" runat="server"/></td>

then <%# Container.DataI tem("ProdID") %doesn't get assigned to the
appropriate ProdID. Rather, the URL of link literally remains as what
is coded above (using <asp:Hyperlink. .>). In other words, irrespective
of whichever 'Remove' link a user clicks, he is taken to

http://myserver/RemoveItem.aspx ?ProdID=<%#%20C ontainer.DataIt em("ProdID")%20 %>

How do I use <%# Container.DataI tem("ProdID") %in the NavigateUrl
property of <asp:Hyperlinki n order to assign the corresponding
database ProdID value to the querystring ProdID so that, for e.g. if
the user clicks the 'Remove' link corresponding to the product whose
ProdID is 10, he is taken to

http://myserver/RemoveItem.aspx?ProdID=10

Oct 1 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
1778
by: Steve Chatham | last post by:
This ought to be simple, but I've not been able to figure out how to do this. I have a request to create a list from a sql database to be displayed in a datagrid on an asp web page. So far, so good. What I now want to do is one of 2 things:
3
5442
by: Henry Johnson | last post by:
Okay - I'm spinning my wheels on this one... can someone help me figure out how to programmatically populate a table cell as follows (from C# code-behind)? I've tried using a Literal control in the TableCell, a HyperLink control, and an Image, but I'm not getting the results I want. Here's the source of what I'm after (retrieved by viewing the source of a page I'm trying to emulate): <td><a...
6
5501
by: Paolo Pignatelli | last post by:
I have an aspx code behind page that goes something like this in the HTML view: <asp:HyperLink id=HyperLink1 runat="server" NavigateUrl='<%#"mailto:" &amp; DataBinder.Eval(Container.DataItem,"StoreEmail") &amp; "&amp;Subject=" &amp; DataBinder.Eval(Container.DataItem,"ProductName") ....
13
7436
by: tperri | last post by:
I have an HTML table with several fields like this: <A href="Savings.aspx?category=Food"><asp:imagebutton id="imgFood" ImageUrl="images\buttons\btn-food-i.gif" runat="server"></asp:imagebutton></A> When the user sees these buttons, they will currently be on the savings.aspx?category=whatever page, and when they click another button to look at other categories, all the links I have around these buttons direct to their various categories.
7
4184
by: Axel Dahmen | last post by:
Hi, within a DataGrid control I'm using a DataTable containing a string column to fill a Hyperlink's href attribute. Unfortunately HttpUtility.UrlEncode() doesn't escape the apostroph character, thus ruining some of my hrefs. How do I correctly escape any character using a Page's current encoding (I don't want to hard-code the encoding)? TIA,
10
20301
by: Lorie0114 | last post by:
Hello, We have an issue that I do not know how to resolve. Our website has several hundred reports. There are a handful of them that are causing issues when there is no interaction for a couple of minutes between client and web server. We are using .NET 2005, Framework 2.0 with an Oracle 9i database. Our application has several hundred reports, but only several reports have this issue; the reports with the issues do not write anything...
4
2364
by: maz77 | last post by:
Hi! I'd like to know what's the difference between <a runat="server" href="tmp.aspx"and <Hyperlink NavigateUrl="tmp.aspx"in VisualStudio2005. What's the better chice? Thanks Max
6
1886
by: Jose Santos | last post by:
I am using a very useful application known as GenericDB by Eli Robillard. I have a classic ASP application that requires that when a specific field contains user comments (not empty) pertaining to a particular field (which is numeric), that numeric field needs to be color highlighted or be marked with an asterisk when displayed on a table. The Lister in GenericDB has the following section that I think is where the modified code needs to be...
0
8704
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8590
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7302
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
6160
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
5620
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
4147
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...
1
2707
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1914
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1591
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.