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

How to create a link in ASP.Net's DataList?

P: n/a
Hello,

I created a datalist in an ASP.Net / VB page.
I display the image and price of a few products.

When a user clicks an image I want to load the page
"detail.aspx?number=id" and send the value of the "id" field of that
record as a URL parameter.

Can someone tell me how to do this.

The code I have is as follows:

<form runat="server">
<asp:DataList id="dlCollection"
runat="server"
RepeatColumns="4"
RepeatDirection="Horizontal"
RepeatLayout="Table"
DataSource="<%# dsCollection.DefaultView %>" >
<HeaderTemplate></HeaderTemplate>
<ItemTemplate>
<table cellspacing="4" cellpadding="4" align="center">
<tr>
<td align="center"><img
src="images/content/collection/<%# dsCollection.FieldValue("imageSmall",
Container) %>" /> </td>
</tr>
<tr>
<td align="center" valign="top"
class="heading_11px_01"><%# dsCollection.FieldValue("price", Container)
%> </td>
</tr>
</table>
</ItemTemplate>
</asp:DataList>
</form>

Thank You,
Miguel

Nov 18 '05 #1
Share this Question
Share on Google+
4 Replies


P: n/a
Hi Miguel,

The easiest way is to put the image inside a hyperlink control and set the
image name from the database. Check out the code below and let us know if it
helps?

Ken
Microsoft MVP [ASP.NET]
<asp:DataList id="dlCollection" runat="server">
<ItemTemplate>
&nbsp;
<asp:HyperLink id="HyperLink1" runat="server" NavigateUrl='<%#
"detail.aspx?number=" & DataBinder.Eval( Container.DataItem, "id") %>'>
<asp:Image id="Image1" runat="server" imageurl='<%#
DataBinder.Eval( Container.DataItem, "imageSmall") %>'></asp:Image>
</asp:HyperLink>
<asp:Label id="lblPrice" runat="server" ><%# DataBinder.Eval(
Container.DataItem, "price") %></asp:Label>
</ItemTemplate>
</asp:DataList>
Private Sub Page_Load _
(ByVal sender As System.Object, _
ByVal e As System.EventArgs) _
Handles MyBase.Load
dlCollection.DataSource = CreateDataSource()
dlCollection.DataBind()

End Sub
Function CreateDataSource() As DataTable
Dim dt As New DataTable
Dim dr As DataRow
dt.Columns.Add(New DataColumn _
("id", GetType(Int32)))
dt.Columns.Add(New DataColumn _
("imageSmall", GetType(String)))
dt.Columns.Add(New DataColumn _
("price", GetType(Double)))
dt.Columns.Add(New DataColumn _
("Boolean", GetType(Boolean)))
Dim i As Integer
For i = 0 To 8
dr = dt.NewRow()
dr(0) = i
dr(1) = "Item " + i.ToString()
dr(2) = 1.23 * (i + 1)
dr(3) = (i = 4)
dt.Rows.Add(dr)
Next i
Return dt
End Function 'CreateDataSource

"Miguel Dias Moura" <we****@27lamps.com> wrote in message
news:eK*************@TK2MSFTNGP11.phx.gbl...
Hello,

I created a datalist in an ASP.Net / VB page.
I display the image and price of a few products.

When a user clicks an image I want to load the page
"detail.aspx?number=id" and send the value of the "id" field of that
record as a URL parameter.

Can someone tell me how to do this.

The code I have is as follows:

<form runat="server">
<asp:DataList id="dlCollection"
runat="server"
RepeatColumns="4"
RepeatDirection="Horizontal"
RepeatLayout="Table"
DataSource="<%# dsCollection.DefaultView %>" >
<HeaderTemplate></HeaderTemplate>
<ItemTemplate>
<table cellspacing="4" cellpadding="4" align="center">
<tr>
<td align="center"><img
src="images/content/collection/<%# dsCollection.FieldValue("imageSmall",
Container) %>" /> </td>
</tr>
<tr>
<td align="center" valign="top"
class="heading_11px_01"><%# dsCollection.FieldValue("price", Container) %>
</td>
</tr>
</table>
</ItemTemplate> </asp:DataList>
</form>

Thank You,
Miguel


Nov 18 '05 #2

P: n/a
Hello,

I was trying your code but I wasn't able to make it work. This seems
really complicated and I am on this for days. Can you look at the code
of my page where everything is working but without the link and tell me
what should I do?

Here is the entire code (I know most of it is not important but I prefer
to send everything just to not miss something):
CODE START
<%@ Page Language="VB" ContentType="text/html"
ResponseEncoding="iso-8859-1" %>
<%@ Register TagPrefix="MM" Namespace="DreamweaverCtrls"
Assembly="DreamweaverCtrls,version=1.0.0.0,publicK eyToken=836f606ede05d46a,culture=neutral"
%>
<MM:DataSet
id="dsArticleLeft"
runat="Server"
IsStoredProcedure="false"
ConnectionString='<%#
System.Configuration.ConfigurationSettings.AppSett ings("MM_CONNECTION_STRING_connJaquelineRoxoAtelie r")
%>'
DatabaseType='<%#
System.Configuration.ConfigurationSettings.AppSett ings("MM_CONNECTION_DATABASETYPE_connJaquelineRoxo Atelier")
%>'
CommandText='<%# "SELECT * FROM articleLeft" %>'
Debug="true"
</MM:DataSet> <MM:DataSet
id="dsArticleRight"
runat="Server"
IsStoredProcedure="false"
ConnectionString='<%#
System.Configuration.ConfigurationSettings.AppSett ings("MM_CONNECTION_STRING_connJaquelineRoxoAtelie r")
%>'
DatabaseType='<%#
System.Configuration.ConfigurationSettings.AppSett ings("MM_CONNECTION_DATABASETYPE_connJaquelineRoxo Atelier")
%>'
CommandText='<%# "SELECT * FROM articleRight" %>'
Debug="true"</MM:DataSet> <MM:DataSet
id="dsCollection"
runat="Server"
IsStoredProcedure="false"
ConnectionString='<%#
System.Configuration.ConfigurationSettings.AppSett ings("MM_CONNECTION_STRING_connJaquelineRoxoAtelie r")
%>'
DatabaseType='<%#
System.Configuration.ConfigurationSettings.AppSett ings("MM_CONNECTION_DATABASETYPE_connJaquelineRoxo Atelier")
%>'
CommandText='<%# "SELECT * FROM collection ORDER BY reference DESC" %>'
CurrentPage='<%# IIf((Request.QueryString("dsCollection_CurrentPage ") <>
Nothing), Request.QueryString("dsCollection_CurrentPage"), 0) %>'
PageSize="12"
Debug="true"</MM:DataSet> <MM:PageBind runat="server" PostBackBind="true" />
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"><!-- InstanceBegin
template="/Templates/basic.dwt.aspx" codeOutsideHTMLIsLocked="false" -->
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"
/>
<!-- InstanceBeginEditable name="doctitle" -->
<title>Jaqueline Roxo - Atelier de Moda em Peles de Pelo</title>
<!-- InstanceEndEditable --><link href="css/styles.css" rel="stylesheet"
type="text/css" />
<script language="JavaScript" type="text/JavaScript">
<!--
function MM_swapImgRestore() { //v3.0
var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++)
x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0;
i<a.length; i++)
if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image;
d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
var p,i,x; if(!d) d=document;
if((p=n.indexOf("?"))>0&&parent.frames.length) {
d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++)
x=d.forms[i][n];
for(i=0;!x&&d.layers&&i<d.layers.length;i++)
x=MM_findObj(n,d.layers[i].document);
if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array;
for(i=0;i<(a.length-2);i+=3)
if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc)
x.oSrc=x.src; x.src=a[i+2];}
}

function P7_autoLayers() { //v1.4 by PVII
var
g,b,k,f,args=P7_autoLayers.arguments;a=parseInt(ar gs[0]);if(isNaN(a))a=0;
if(!document.p7setc){p7c=new Array();document.p7setc=true;for(var
u=0;u<10;u++){
p7c[u]=new
Array();}}for(k=0;k<p7c[a].length;k++){if((g=MM_findObj(p7c[a][k]))!=null){

b=(document.layers)?g:g.style;b.visibility="hidden ";}}for(k=1;k<args.length;k++){

if((g=MM_findObj(args[k]))!=null){b=(document.layers)?g:g.style;b.visibili ty="visible";f=false;
for(var j=0;j<p7c[a].length;j++){if(args[k]==p7c[a][j]) {f=true;}}
if(!f){p7c[a][p7c[a].length++]=args[k];}}}
}
//-->
</script>
<meta name="title" content="Jaqueline Roxo - Atelier de Moda em Peles de
Pelo" />
<meta name="description" content="Atelier situado em Lisboa. Somos
especializados em peles de pelo, comercializamos, produzimos e
modificamos qualquer artigo em Pelo." />
<meta name="keywords" content="peles,pelo,moda,lisboa"/>
<meta name="language" content="Portuguese" />
<meta name="author" content="27 Lamps" />
<meta name="copyright" content="2004 Jaqueline Roxo Atelier" />
<meta name="reply-to" content="ge***@jaquelineroxoatelier.com" />
<meta name="document-classification" content="Fashion" />
<meta name="document-type" content="Web Page" />
<meta name="document-rating" content="Safe for Kids" />
<script language="JavaScript" type="text/JavaScript">
<!--
function MM_reloadPage(init) { //reloads the window if Nav4 resized
if (init==true) with (navigator) {if
((appName=="Netscape")&&(parseInt(appVersion)==4)) {
document.MM_pgW=innerWidth; document.MM_pgH=innerHeight;
onresize=MM_reloadPage; }}
else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH)
location.reload();
}
MM_reloadPage(true);

function P7_Snap() { //v2.65 by PVII
var
x,y,ox,bx,oy,p,tx,a,b,k,d,da,e,el,tw,q0,xx,yy,w1,p a='px',args=P7_Snap.arguments;a=parseInt(a);
if(document.layers||window.opera){pa='';}for(k=0;k <(args.length);k+=4){
if((g=MM_findObj(args[k]))!=null){if((el=MM_findObj(args[k+1]))!=null){

a=parseInt(args[k+2]);b=parseInt(args[k+3]);x=0;y=0;ox=0;oy=0;p="";tx=1;
da="document.all['"+args[k]+"']";if(document.getElementById){
d="document.getElementsByName('"+args[k]+"')[0]";if(!eval(d)){
d="document.getElementById('"+args[k]+"')";if(!eval(d)){d=da;}}
}else
if(document.all){d=da;}if(document.all||document.g etElementById){while(tx==1){

p+=".offsetParent";if(eval(d+p)){x+=parseInt(eval( d+p+".offsetLeft"));y+=parseInt(eval(d+p+".offsetT op"));

}else{tx=0;}}ox=parseInt(g.offsetLeft);oy=parseInt (g.offsetTop);tw=x+ox+y+oy;
if(tw==0||(navigator.appVersion.indexOf("MSIE
4")>-1&&navigator.appVersion.indexOf("Mac")>-1)){

ox=0;oy=0;if(g.style.left){x=parseInt(g.style.left );y=parseInt(g.style.top);}else{

w1=parseInt(el.style.width);bx=(a<0)?-5-w1:-10;a=(Math.abs(a)<1000)?0:a;b=(Math.abs(b)<1000)?0 :b;

x=document.body.scrollLeft+event.clientX+bx;y=docu ment.body.scrollTop+event.clientY;}}
}else if(document.layers){x=g.x;y=g.y;q0=document.layers ,dd="";for(var
s=0;s<q0.length;s++){

dd='document.'+q0[s].name;if(eval(dd+'.document.'+args[k])){x+=eval(dd+'.left');y+=eval(dd+'.top');

break;}}}e=(document.layers)?el:el.style;xx=parseI nt(x+ox+a),yy=parseInt(y+oy+b);
if(navigator.appVersion.indexOf("MSIE 5")>-1 &&
navigator.appVersion.indexOf("Mac")>-1){

xx+=parseInt(document.body.leftMargin);yy+=parseIn t(document.body.topMargin);}
e.left=xx+pa;e.top=yy+pa;}}}
}

function P7_hideEl(evt) { //v1.5 by PVII-www.projectseven.com
var b,r,m=false;if(document.layers){b=evt.target;if(b. p7aHide){
b.visibility="hidden";}else{routeEvent(evt);}
}else if(document.all&&!window.opera){b=event.srcElement ;while(b){

if(b.p7aHide){break;}b=b.parentElement;}if(!b.cont ains(event.toElement)){
b.style.visibility="hidden";}}else if(document.getElementById){
b=evt.currentTarget;r=evt.relatedTarget;while(r){i f(b==r){m=true;
break;}r=r.parentNode;}if(!m){b.style.visibility=" hidden";}}
}

function P7_autoHide() { //v1.5 by PVII-www.projectseven.com
var i,g;for(i=0;i<arguments.length;i++){

if((g=MM_findObj(arguments[i]))!=null){g.p7aHide=true;if(document.layers){
g.captureEvents(Event.MOUSEOUT);}g.onmouseout=P7_h ideEl;}}
}
//-->
</script>
<!-- InstanceBeginEditable name="head" --><!-- InstanceEndEditable -->
</head><body
onload="MM_preloadImages('images/design/button-coleccao-over.gif','images/button-servicos.over.gif','images/design/button-atelier-over.gif','images/design/button-luxus-over.gif','images/design/button-contactos-over.gif','images/design/button-home-over.gif','images/design/button-servicos-over.gif');P7_autoHide('submenu')">
<div id="submenu">
<table border="0" cellspacing="0" cellpadding="0">
<tr>
<td><a href="coleccao-filter.aspx?type=astracan"
onmouseout="MM_swapImgRestore()"
onmouseover="MM_swapImage('astracan','','images/design/button-astracan-over.gif',1)"><img
src="images/design/button-astracan.gif" alt="astracan" name="astracan"
width="100" height="20" border="0" id="astracan" /></a></td>
</tr>
<tr>
<td><a href="coleccao-filter.aspx?type=castor"
onmouseout="MM_swapImgRestore()"
onmouseover="MM_swapImage('castor','','images/design/button-castor-over.gif',1)"><img
src="images/design/button-castor.gif" alt="castor" name="castor"
width="100" height="20" border="0" id="castor" /></a></td>
</tr>
<tr>
<td><a href="coleccao-filter.aspx?type=chinchila"
onmouseout="MM_swapImgRestore()"
onmouseover="MM_swapImage('chinchila','','images/design/button-chinchila-over.gif',1)"><img
src="images/design/button-chinchila.gif" alt="chinchila"
name="chinchila" width="100" height="20" border="0" id="chinchila"
/></a></td>
</tr>
<tr>
<td><a href="coleccao-filter.aspx?type=lapin"
onmouseout="MM_swapImgRestore()"
onmouseover="MM_swapImage('lapin','','images/design/button-lapin-over.gif',1)"><img
src="images/design/button-lapin.gif" alt="lapin" name="lapin"
width="100" height="20" border="0" id="lapin" /></a></td>
</tr>
<tr>
<td><a href="coleccao-filter.aspx?type=opossuma"
onmouseout="MM_swapImgRestore()"
onmouseover="MM_swapImage('opossuma','','images/design/button-opossuma-over.gif',1)"><img
src="images/design/button-opossuma.gif" alt="opossuma" name="opossuma"
width="100" height="20" border="0" id="opossuma" /></a></td>
</tr>
<tr>
<td><a href="coleccao-filter.aspx?type=raposa"
onmouseout="MM_swapImgRestore()"
onmouseover="MM_swapImage('raposa','','images/design/button-raposa-over.gif',1)"><img
src="images/design/button-raposa.gif" alt="raposa" name="raposa"
width="100" height="20" border="0" id="raposa" /></a></td>
</tr>
<tr>
<td><a href="coleccao-filter.aspx?type=vison"
onmouseout="MM_swapImgRestore()"
onmouseover="MM_swapImage('vison','','images/design/button-vison-over.gif',1)"><img
src="images/design/button-vison.gif" alt="vison" name="vison"
width="100" height="20" border="0" id="vison" /></a></td>
</tr>
</table>
</div>
<div id="wrapper">
<div id="header"><img src="images/design/logo-jratelier.jpg" width="680"
height="55" border="0" onmouseover="P7_autoLayers(0)" /></div>
<!-- InstanceBeginEditable name="menu" -->
<div id="menu"><a href="index.aspx" onmouseout="MM_swapImgRestore()"
onmouseover="MM_swapImage('home','','images/design/button-home-over.gif',1)"><img
src="images/design/button-home.gif" alt="home" name="home" width="52"
height="20" border="0" id="home" onmouseover="P7_autoLayers(0)" /></a><a
href="coleccao.aspx"
onmouseover="P7_autoLayers(0,'submenu');MM_swapIma ge('coleccao','','images/design/button-coleccao-over.gif',1);P7_Snap('coleccao','submenu',0,21)"
onmouseout="MM_swapImgRestore()"><img
src="images/design/button-coleccao-hit.gif" alt="colecÁ„o"
name="coleccao" width="72" height="20" border="0" id="coleccao" /></a><a
href="servicos.aspx"
onmouseover="MM_swapImage('servicos','','images/design/button-servicos-over.gif',1);P7_autoLayers(0)"
onmouseout="MM_swapImgRestore()"><img
src="images/design/button-servicos.gif" alt="serviÁos" name="servicos"
width="70" height="20" border="0" id="servicos" /></a><a
href="atelier.aspx" onmouseout="MM_swapImgRestore()"
onmouseover="MM_swapImage('atelier','','images/design/button-atelier-over.gif',1)"><img
src="images/design/button-atelier.gif" alt="atelier" name="atelier"
width="59" height="20" border="0" id="atelier" /></a><a
href="luxus.aspx" onmouseout="MM_swapImgRestore()"
onmouseover="MM_swapImage('luxos','','images/design/button-luxus-over.gif',1)"><img
src="images/design/button-luxus.gif" alt="luxo's" name="luxos"
width="54" height="20" border="0" id="luxos" /></a><a
href="contactos.aspx" onmouseout="MM_swapImgRestore()"
onmouseover="MM_swapImage('contactos','','images/design/button-contactos-over.gif',1)"><img
src="images/design/button-contactos.gif" alt="contactos"
name="contactos" width="80" height="20" border="0" id="contactos"
/></a></div>
<!-- InstanceEndEditable --><!-- InstanceBeginEditable name="content"
-->
<div id="content">
<table width="675" border="0" cellpadding="4" cellspacing="2">
<tr>
<td align="center"><p><img
src="images/content/coleccao20042005.gif" width="321" height="25"
/></p></td>
</tr>
</table>
<table width="675" border="0" cellpadding="0" cellspacing="0">
<tr>
<td align="center" valign="top"><table width="660" border="0"
cellpadding="2" cellspacing="2" class="bottomBorder_CCCCCC">
<tr>
<td align="left"><div align="justify"><span
class="text_11px_01">Din&acirc;mica e sens&iacute;vel, esta
colec&ccedil;&atilde;o define um estilo urbano mas elegante.
Pr&aacute;tica para um uso di&aacute;rio e sofisticada para momentos
especiais. &Eacute; a arte do camale&atilde;o consoante a altura do dia:
inspiradora e audaz pela manh&atilde;, elegante e sofisticada &aacute;
noite as peles pela sua qualidade e desing ajustam-se perfeitamente a
qualquer ocasi&atilde;o.</span></div></td>
</tr>
</table> </td>
</tr>
</table>
<table border="0" cellpadding="2" cellspacing="5" align="center"
valign="top">
<tr>
<td align="left" valign="top"><p class="text_11px_01">
<form runat="server">
<asp:DataList id="dlCollection"
runat="server"
RepeatColumns="4"
RepeatDirection="Horizontal"
RepeatLayout="Table"
DataSource="<%# dsCollection.DefaultView %>" >
<HeaderTemplate></HeaderTemplate>
<ItemTemplate>
<table cellspacing="4" cellpadding="4" align="center">
<tr>
<td align="center"><img
src="images/content/collection/<%# dsCollection.FieldValue("imageSmall",
Container) %>" /> </td>
</tr>
<tr>
<td align="center" valign="top"
class="heading_11px_01"><%# dsCollection.FieldValue("price", Container)
%> </td>
</tr>
</table>
</ItemTemplate>
</asp:DataList>
</form>
</p></td>
</tr>
</table>
<table width="675" border="0" cellpadding="0" cellspacing="0"
class="heading_11px_01">
<tr>
<td align="center" valign="top"><table width="660" border="0"
cellpadding="4" cellspacing="2" class="topBorder_CCCCCC">
<tr>
<td align="center" valign="middle"><div
align="justify"></div>
<MM:If runat="server" Expression='<%#
(dsCollection.CurrentPage <> 0) %>'>
<ContentsTemplate><a href="<%#
Request.ServerVariables("SCRIPT_NAME") %>?dsCollection_currentPage=<%#
Math.Max(dsCollection.CurrentPage - 1, 0)
%>">Anterior</a></ContentsTemplate>
</MM:If>
&nbsp;&nbsp;|&nbsp;<%= IIf((dsCollection.RecordCount =
0), 0, (dsCollection.StartRecord + 1)) %>..<%= dsCollection.EndRecord
%>&nbsp;de <%= dsCollection.RecordCount %>&nbsp;|&nbsp;&nbsp;
<MM:If runat="server" Expression='<%#
(dsCollection.CurrentPage < dsCollection.LastPage) %>'>
<ContentsTemplate><a href="<%#
Request.ServerVariables("SCRIPT_NAME") %>?dsCollection_currentPage=<%#
Math.Min(dsCollection.CurrentPage + 1, dsCollection.LastPage)
%>">Seguinte</a></ContentsTemplate>
</MM:If></td>
</tr>
</table></td>
</tr>
</table>
</div>
<!-- InstanceEndEditable -->
<div id="articles">
<table width="670px" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="335" align="left" valign="top"><table border="0"
cellspacing="0" cellpadding="3">
<tr>
<td align="left" valign="top"><img src='images/content/<%#
dsArticleLeft.FieldValue("image", Container) %>' /></td>
<td align="left" valign="top"><table border="0"
cellspacing="0" cellpadding="0">
<tr>
<td class="heading_12px_02"><%#
dsArticleLeft.FieldValue("title", Container) %></td>
</tr>
</table>
<table width="240" border="0" cellspacing="0"
cellpadding="1">
<tr>
<td class="text_11px_02"><div align="left"><%#
dsArticleLeft.FieldValue("description", Container) %></div></td>
</tr>
</table>
<table width="220" border="0" cellpadding="2"
cellspacing="0">
<tr>
<td class="text_11px_02"><div align="right"><%#
DateTime.Parse(dsArticleLeft.FieldValue("date",
Container)).ToString("dd-MM-yyyy") %></div></td>
</tr>
</table></td>
</tr>
</table></td>
<td width="335" align="left" valign="top"><table border="0"
cellspacing="0" cellpadding="3">
<tr>
<td align="left" valign="top"><img src='images/content/<%#
dsArticleRight.FieldValue("image", Container) %>' /></td>
<td align="left" valign="top"><table border="0"
cellspacing="0" cellpadding="0">
<tr>
<td class="heading_12px_02"><%#
dsArticleRight.FieldValue("title", Container) %></td>
</tr>
</table>
<table width="240" border="0" cellspacing="0"
cellpadding="1">
<tr>
<td class="text_11px_02"><div align="left"><%#
dsArticleRight.FieldValue("description", Container) %></div></td>
</tr>
</table>
<table width="220" border="0" cellpadding="2"
cellspacing="0">
<tr>
<td class="text_11px_02"><div align="right"><%#
DateTime.Parse(dsArticleRight.FieldValue("date",
Container)).ToString("dd-MM-yyyy") %></div></td>
</tr>
</table></td>
</tr>
</table></td>
</tr>
</table>
</div>
<div id="footer">
<table border="0" cellspacing="0" cellpadding="0">
<tr>
<td valign="middle" class="text_11px_03">&copy; 2004 Jaqueline
Roxo Atelier, todos os direitos reservados </td>
</tr>
</table>
</div>
</div>
</body>
<!-- InstanceEnd --></html>
CODE END


Thank You,
Miguel
"Ken Cox [Microsoft MVP]" <BA************@sympatico.ca> wrote in message
news:e0**************@TK2MSFTNGP11.phx.gbl: Hi Miguel,

The easiest way is to put the image inside a hyperlink control and set the

image name from the database. Check out the code below and let us know if
it
helps?

Ken
Microsoft MVP [ASP.NET]
<asp:DataList id="dlCollection" runat="server">
<ItemTemplate>
&nbsp;
<asp:HyperLink id="HyperLink1" runat="server" NavigateUrl='<%#
"detail.aspx?number=" & DataBinder.Eval( Container.DataItem, "id") %>'>
<asp:Image id="Image1" runat="server" imageurl='<%#
DataBinder.Eval( Container.DataItem, "imageSmall") %>'></asp:Image>
</asp:HyperLink>
<asp:Label id="lblPrice" runat="server" ><%# DataBinder.Eval(
Container.DataItem, "price") %></asp:Label>
</ItemTemplate>
</asp:DataList>
Private Sub Page_Load _
(ByVal sender As System.Object, _
ByVal e As System.EventArgs) _
Handles MyBase.Load
dlCollection.DataSource = CreateDataSource()
dlCollection.DataBind()

End Sub
Function CreateDataSource() As DataTable
Dim dt As New DataTable
Dim dr As DataRow
dt.Columns.Add(New DataColumn _
("id", GetType(Int32)))
dt.Columns.Add(New DataColumn _
("imageSmall", GetType(String)))
dt.Columns.Add(New DataColumn _
("price", GetType(Double)))
dt.Columns.Add(New DataColumn _
("Boolean", GetType(Boolean)))
Dim i As Integer
For i = 0 To 8
dr = dt.NewRow()
dr(0) = i
dr(1) = "Item " + i.ToString()
dr(2) = 1.23 * (i + 1)
dr(3) = (i = 4)
dt.Rows.Add(dr)
Next i
Return dt
End Function 'CreateDataSource

"Miguel Dias Moura" <we****@27lamps.com> wrote in message
news:eK*************@TK2MSFTNGP11.phx.gbl...
Hello,

I created a datalist in an ASP.Net / VB page.
I display the image and price of a few products.

When a user clicks an image I want to load the page
"detail.aspx?number=id" and send the value of the "id" field of that
record as a URL parameter.

Can someone tell me how to do this.

The code I have is as follows:

<form runat="server">
<asp:DataList id="dlCollection"
runat="server"
RepeatColumns="4"
RepeatDirection="Horizontal"
RepeatLayout="Table"
DataSource="<%# dsCollection.DefaultView %>" >
<HeaderTemplate></HeaderTemplate>
<ItemTemplate>
<table cellspacing="4" cellpadding="4" align="center">
<tr>
<td align="center"><img
src="images/content/collection/<%# dsCollection.FieldValue("imageSmall",

Container) %>" /> </td>
</tr>
<tr>
<td align="center" valign="top"
class="heading_11px_01"><%# dsCollection.FieldValue("price", Container)
%>
</td>
</tr>
</table>
</ItemTemplate> </asp:DataList>
</form>

Thank You,
Miguel


Nov 18 '05 #3

P: n/a
Ouch. You seem to be using DreamWeaver which has its own way of doing
ASP.NET. You might be better off posting in a Macromedia newsgroup where
people understand DreamWeaver's controls.

"Miguel Dias Moura" wrote:
Hello,

I was trying your code but I wasn't able to make it work. This seems
really complicated and I am on this for days. Can you look at the code
of my page where everything is working but without the link and tell me
what should I do?

Here is the entire code (I know most of it is not important but I prefer
to send everything just to not miss something):
CODE START
<%@ Page Language="VB" ContentType="text/html"
ResponseEncoding="iso-8859-1" %>
<%@ Register TagPrefix="MM" Namespace="DreamweaverCtrls"
Assembly="DreamweaverCtrls,version=1.0.0.0,publicK eyToken=836f606ede05d46a,culture=neutral"
%>
<MM:DataSet
id="dsArticleLeft"
runat="Server"
IsStoredProcedure="false"
ConnectionString='<%#
System.Configuration.ConfigurationSettings.AppSett ings("MM_CONNECTION_STRING_connJaquelineRoxoAtelie r")
%>'
DatabaseType='<%#
System.Configuration.ConfigurationSettings.AppSett ings("MM_CONNECTION_DATABASETYPE_connJaquelineRoxo Atelier")
%>'
CommandText='<%# "SELECT * FROM articleLeft" %>'
Debug="true"
</MM:DataSet>

<MM:DataSet
id="dsArticleRight"
runat="Server"
IsStoredProcedure="false"
ConnectionString='<%#
System.Configuration.ConfigurationSettings.AppSett ings("MM_CONNECTION_STRING_connJaquelineRoxoAtelie r")
%>'
DatabaseType='<%#
System.Configuration.ConfigurationSettings.AppSett ings("MM_CONNECTION_DATABASETYPE_connJaquelineRoxo Atelier")
%>'
CommandText='<%# "SELECT * FROM articleRight" %>'
Debug="true"
</MM:DataSet>

<MM:DataSet
id="dsCollection"
runat="Server"
IsStoredProcedure="false"
ConnectionString='<%#
System.Configuration.ConfigurationSettings.AppSett ings("MM_CONNECTION_STRING_connJaquelineRoxoAtelie r")
%>'
DatabaseType='<%#
System.Configuration.ConfigurationSettings.AppSett ings("MM_CONNECTION_DATABASETYPE_connJaquelineRoxo Atelier")
%>'
CommandText='<%# "SELECT * FROM collection ORDER BY reference DESC" %>'
CurrentPage='<%# IIf((Request.QueryString("dsCollection_CurrentPage ") <>
Nothing), Request.QueryString("dsCollection_CurrentPage"), 0) %>'
PageSize="12"
Debug="true"
</MM:DataSet>

<MM:PageBind runat="server" PostBackBind="true" />
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"><!-- InstanceBegin
template="/Templates/basic.dwt.aspx" codeOutsideHTMLIsLocked="false" -->
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"
/>
<!-- InstanceBeginEditable name="doctitle" -->
<title>Jaqueline Roxo - Atelier de Moda em Peles de Pelo</title>
<!-- InstanceEndEditable --><link href="css/styles.css" rel="stylesheet"
type="text/css" />
<script language="JavaScript" type="text/JavaScript">
<!--
function MM_swapImgRestore() { //v3.0
var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++)
x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0;
i<a.length; i++)
if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image;
d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
var p,i,x; if(!d) d=document;
if((p=n.indexOf("?"))>0&&parent.frames.length) {
d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++)
x=d.forms[i][n];
for(i=0;!x&&d.layers&&i<d.layers.length;i++)
x=MM_findObj(n,d.layers[i].document);
if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array;
for(i=0;i<(a.length-2);i+=3)
if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc)
x.oSrc=x.src; x.src=a[i+2];}
}

function P7_autoLayers() { //v1.4 by PVII
var
g,b,k,f,args=P7_autoLayers.arguments;a=parseInt(ar gs[0]);if(isNaN(a))a=0;
if(!document.p7setc){p7c=new Array();document.p7setc=true;for(var
u=0;u<10;u++){
p7c[u]=new
Array();}}for(k=0;k<p7c[a].length;k++){if((g=MM_findObj(p7c[a][k]))!=null){

b=(document.layers)?g:g.style;b.visibility="hidden ";}}for(k=1;k<args.length;k++){

if((g=MM_findObj(args[k]))!=null){b=(document.layers)?g:g.style;b.visibili ty="visible";f=false;
for(var j=0;j<p7c[a].length;j++){if(args[k]==p7c[a][j]) {f=true;}}
if(!f){p7c[a][p7c[a].length++]=args[k];}}}
}
//-->
</script>
<meta name="title" content="Jaqueline Roxo - Atelier de Moda em Peles de
Pelo" />
<meta name="description" content="Atelier situado em Lisboa. Somos
especializados em peles de pelo, comercializamos, produzimos e
modificamos qualquer artigo em Pelo." />
<meta name="keywords" content="peles,pelo,moda,lisboa"/>
<meta name="language" content="Portuguese" />
<meta name="author" content="27 Lamps" />
<meta name="copyright" content="2004 Jaqueline Roxo Atelier" />
<meta name="reply-to" content="ge***@jaquelineroxoatelier.com" />
<meta name="document-classification" content="Fashion" />
<meta name="document-type" content="Web Page" />
<meta name="document-rating" content="Safe for Kids" />
<script language="JavaScript" type="text/JavaScript">
<!--
function MM_reloadPage(init) { //reloads the window if Nav4 resized
if (init==true) with (navigator) {if
((appName=="Netscape")&&(parseInt(appVersion)==4)) {
document.MM_pgW=innerWidth; document.MM_pgH=innerHeight;
onresize=MM_reloadPage; }}
else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH)
location.reload();
}
MM_reloadPage(true);

function P7_Snap() { //v2.65 by PVII
var
x,y,ox,bx,oy,p,tx,a,b,k,d,da,e,el,tw,q0,xx,yy,w1,p a='px',args=P7_Snap.arguments;a=parseInt(a);
if(document.layers||window.opera){pa='';}for(k=0;k <(args.length);k+=4){
if((g=MM_findObj(args[k]))!=null){if((el=MM_findObj(args[k+1]))!=null){

a=parseInt(args[k+2]);b=parseInt(args[k+3]);x=0;y=0;ox=0;oy=0;p="";tx=1;
da="document.all['"+args[k]+"']";if(document.getElementById){
d="document.getElementsByName('"+args[k]+"')[0]";if(!eval(d)){
d="document.getElementById('"+args[k]+"')";if(!eval(d)){d=da;}}
}else
if(document.all){d=da;}if(document.all||document.g etElementById){while(tx==1){

p+=".offsetParent";if(eval(d+p)){x+=parseInt(eval( d+p+".offsetLeft"));y+=parseInt(eval(d+p+".offsetT op"));

}else{tx=0;}}ox=parseInt(g.offsetLeft);oy=parseInt (g.offsetTop);tw=x+ox+y+oy;
if(tw==0||(navigator.appVersion.indexOf("MSIE
4")>-1&&navigator.appVersion.indexOf("Mac")>-1)){

ox=0;oy=0;if(g.style.left){x=parseInt(g.style.left );y=parseInt(g.style.top);}else{

w1=parseInt(el.style.width);bx=(a<0)?-5-w1:-10;a=(Math.abs(a)<1000)?0:a;b=(Math.abs(b)<1000)?0 :b;

x=document.body.scrollLeft+event.clientX+bx;y=docu ment.body.scrollTop+event.clientY;}}
}else if(document.layers){x=g.x;y=g.y;q0=document.layers ,dd="";for(var
s=0;s<q0.length;s++){

dd='document.'+q0[s].name;if(eval(dd+'.document.'+args[k])){x+=eval(dd+'.left');y+=eval(dd+'.top');

break;}}}e=(document.layers)?el:el.style;xx=parseI nt(x+ox+a),yy=parseInt(y+oy+b);
if(navigator.appVersion.indexOf("MSIE 5")>-1 &&
navigator.appVersion.indexOf("Mac")>-1){

xx+=parseInt(document.body.leftMargin);yy+=parseIn t(document.body.topMargin);}
e.left=xx+pa;e.top=yy+pa;}}}
}

function P7_hideEl(evt) { //v1.5 by PVII-www.projectseven.com
var b,r,m=false;if(document.layers){b=evt.target;if(b. p7aHide){
b.visibility="hidden";}else{routeEvent(evt);}
}else if(document.all&&!window.opera){b=event.srcElement ;while(b){

if(b.p7aHide){break;}b=b.parentElement;}if(!b.cont ains(event.toElement)){
b.style.visibility="hidden";}}else if(document.getElementById){
b=evt.currentTarget;r=evt.relatedTarget;while(r){i f(b==r){m=true;
break;}r=r.parentNode;}if(!m){b.style.visibility=" hidden";}}
}

function P7_autoHide() { //v1.5 by PVII-www.projectseven.com
var i,g;for(i=0;i<arguments.length;i++){

if((g=MM_findObj(arguments[i]))!=null){g.p7aHide=true;if(document.layers){
g.captureEvents(Event.MOUSEOUT);}g.onmouseout=P7_h ideEl;}}
}
//-->
</script>
<!-- InstanceBeginEditable name="head" --><!-- InstanceEndEditable -->
</head><body
onload="MM_preloadImages('images/design/button-coleccao-over.gif','images/button-servicos.over.gif','images/design/button-atelier-over.gif','images/design/button-luxus-over.gif','images/design/button-contactos-over.gif','images/design/button-home-over.gif','images/design/button-servicos-over.gif');P7_autoHide('submenu')">
<div id="submenu">
<table border="0" cellspacing="0" cellpadding="0">
<tr>
<td><a href="coleccao-filter.aspx?type=astracan"
onmouseout="MM_swapImgRestore()"
onmouseover="MM_swapImage('astracan','','images/design/button-astracan-over.gif',1)"><img
src="images/design/button-astracan.gif" alt="astracan" name="astracan"
width="100" height="20" border="0" id="astracan" /></a></td>
</tr>
<tr>
<td><a href="coleccao-filter.aspx?type=castor"
onmouseout="MM_swapImgRestore()"
onmouseover="MM_swapImage('castor','','images/design/button-castor-over.gif',1)"><img
src="images/design/button-castor.gif" alt="castor" name="castor"
width="100" height="20" border="0" id="castor" /></a></td>
</tr>
<tr>
<td><a href="coleccao-filter.aspx?type=chinchila"
onmouseout="MM_swapImgRestore()"
onmouseover="MM_swapImage('chinchila','','images/design/button-chinchila-over.gif',1)"><img
src="images/design/button-chinchila.gif" alt="chinchila"
name="chinchila" width="100" height="20" border="0" id="chinchila"
/></a></td>
</tr>
<tr>
<td><a href="coleccao-filter.aspx?type=lapin"
onmouseout="MM_swapImgRestore()"
onmouseover="MM_swapImage('lapin','','images/design/button-lapin-over.gif',1)"><img
src="images/design/button-lapin.gif" alt="lapin" name="lapin"
width="100" height="20" border="0" id="lapin" /></a></td>
</tr>
<tr>
<td><a href="coleccao-filter.aspx?type=opossuma"
onmouseout="MM_swapImgRestore()"
onmouseover="MM_swapImage('opossuma','','images/design/button-opossuma-over.gif',1)"><img
src="images/design/button-opossuma.gif" alt="opossuma" name="opossuma"
width="100" height="20" border="0" id="opossuma" /></a></td>
</tr>
<tr>
<td><a href="coleccao-filter.aspx?type=raposa"
onmouseout="MM_swapImgRestore()"
onmouseover="MM_swapImage('raposa','','images/design/button-raposa-over.gif',1)"><img
src="images/design/button-raposa.gif" alt="raposa" name="raposa"
width="100" height="20" border="0" id="raposa" /></a></td>
</tr>
<tr>
<td><a href="coleccao-filter.aspx?type=vison"
onmouseout="MM_swapImgRestore()"
onmouseover="MM_swapImage('vison','','images/design/button-vison-over.gif',1)"><img
src="images/design/button-vison.gif" alt="vison" name="vison"
width="100" height="20" border="0" id="vison" /></a></td>
</tr>
</table>
</div>
<div id="wrapper">
<div id="header"><img src="images/design/logo-jratelier.jpg" width="680"
height="55" border="0" onmouseover="P7_autoLayers(0)" /></div>
<!-- InstanceBeginEditable name="menu" -->
<div id="menu"><a href="index.aspx" onmouseout="MM_swapImgRestore()"
onmouseover="MM_swapImage('home','','images/design/button-home-over.gif',1)"><img
src="images/design/button-home.gif" alt="home" name="home" width="52"
height="20" border="0" id="home" onmouseover="P7_autoLayers(0)" /></a><a
href="coleccao.aspx"
onmouseover="P7_autoLayers(0,'submenu');MM_swapIma ge('coleccao','','images/design/button-coleccao-over.gif',1);P7_Snap('coleccao','submenu',0,21)"
onmouseout="MM_swapImgRestore()"><img
src="images/design/button-coleccao-hit.gif" alt="colecção"
name="coleccao" width="72" height="20" border="0" id="coleccao" /></a><a
href="servicos.aspx"
onmouseover="MM_swapImage('servicos','','images/design/button-servicos-over.gif',1);P7_autoLayers(0)"
onmouseout="MM_swapImgRestore()"><img
src="images/design/button-servicos.gif" alt="serviços" name="servicos"
width="70" height="20" border="0" id="servicos" /></a><a
href="atelier.aspx" onmouseout="MM_swapImgRestore()"
onmouseover="MM_swapImage('atelier','','images/design/button-atelier-over.gif',1)"><img
src="images/design/button-atelier.gif" alt="atelier" name="atelier"
width="59" height="20" border="0" id="atelier" /></a><a
href="luxus.aspx" onmouseout="MM_swapImgRestore()"
onmouseover="MM_swapImage('luxos','','images/design/button-luxus-over.gif',1)"><img
src="images/design/button-luxus.gif" alt="luxo's" name="luxos"
width="54" height="20" border="0" id="luxos" /></a><a
href="contactos.aspx" onmouseout="MM_swapImgRestore()"
onmouseover="MM_swapImage('contactos','','images/design/button-contactos-over.gif',1)"><img
src="images/design/button-contactos.gif" alt="contactos"
name="contactos" width="80" height="20" border="0" id="contactos"
/></a></div>
<!-- InstanceEndEditable --><!-- InstanceBeginEditable name="content"
-->
<div id="content">
<table width="675" border="0" cellpadding="4" cellspacing="2">
<tr>
<td align="center"><p><img
src="images/content/coleccao20042005.gif" width="321" height="25"
/></p></td>
</tr>
</table>
<table width="675" border="0" cellpadding="0" cellspacing="0">
<tr>
<td align="center" valign="top"><table width="660" border="0"
cellpadding="2" cellspacing="2" class="bottomBorder_CCCCCC">
<tr>
<td align="left"><div align="justify"><span
class="text_11px_01">Din√Ęmica e sens√*vel, esta
colecção define um estilo urbano mas elegante.
Pr√°tica para um uso di√°rio e sofisticada para momentos
especiais. √Č a arte do camale√£o consoante a altura do dia:
inspiradora e audaz pela manh√£, elegante e sofisticada √°
noite as peles pela sua qualidade e desing ajustam-se perfeitamente a
qualquer ocasi√£o.</span></div></td>
</tr>
</table> </td>
</tr>
</table>
<table border="0" cellpadding="2" cellspacing="5" align="center"
valign="top">
<tr>
<td align="left" valign="top"><p class="text_11px_01">
<form runat="server">
<asp:DataList id="dlCollection"
runat="server"
RepeatColumns="4"
RepeatDirection="Horizontal"
RepeatLayout="Table"
DataSource="<%# dsCollection.DefaultView %>" >
<HeaderTemplate></HeaderTemplate>
<ItemTemplate>
<table cellspacing="4" cellpadding="4" align="center">
<tr>
<td align="center"><img
src="images/content/collection/<%# dsCollection.FieldValue("imageSmall",
Container) %>" /> </td>
</tr>
<tr>
<td align="center" valign="top"
class="heading_11px_01"><%# dsCollection.FieldValue("price", Container)
%> </td>
</tr>
</table>
</ItemTemplate>
</asp:DataList>
</form>
</p></td>
</tr>
</table>
<table width="675" border="0" cellpadding="0" cellspacing="0"
class="heading_11px_01">
<tr>
<td align="center" valign="top"><table width="660" border="0"
cellpadding="4" cellspacing="2" class="topBorder_CCCCCC">
<tr>
<td align="center" valign="middle"><div
align="justify"></div>
<MM:If runat="server" Expression='<%#
(dsCollection.CurrentPage <> 0) %>'>
<ContentsTemplate><a href="<%#
Request.ServerVariables("SCRIPT_NAME") %>?dsCollection_currentPage=<%#
Math.Max(dsCollection.CurrentPage - 1, 0)
%>">Anterior</a></ContentsTemplate>
</MM:If>
| <%= IIf((dsCollection.RecordCount =
0), 0, (dsCollection.StartRecord + 1)) %>..<%= dsCollection.EndRecord
%> de <%= dsCollection.RecordCount %> |
<MM:If runat="server" Expression='<%#
(dsCollection.CurrentPage < dsCollection.LastPage) %>'>
<ContentsTemplate><a href="<%#
Request.ServerVariables("SCRIPT_NAME") %>?dsCollection_currentPage=<%#
Math.Min(dsCollection.CurrentPage + 1, dsCollection.LastPage)
%>">Seguinte</a></ContentsTemplate>
</MM:If></td>
</tr>
</table></td>
</tr>
</table>
</div>
<!-- InstanceEndEditable -->
<div id="articles">
<table width="670px" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="335" align="left" valign="top"><table border="0"
cellspacing="0" cellpadding="3">
<tr>
<td align="left" valign="top"><img src='images/content/<%#
dsArticleLeft.FieldValue("image", Container) %>' /></td>
<td align="left" valign="top"><table border="0"
cellspacing="0" cellpadding="0">
<tr>
<td class="heading_12px_02"><%#
dsArticleLeft.FieldValue("title", Container) %></td>
</tr>
</table>
<table width="240" border="0" cellspacing="0"
cellpadding="1">
<tr>
<td class="text_11px_02"><div align="left"><%#
dsArticleLeft.FieldValue("description", Container) %></div></td>
</tr>
</table>
<table width="220" border="0" cellpadding="2"
cellspacing="0">
<tr>
<td class="text_11px_02"><div align="right"><%#
DateTime.Parse(dsArticleLeft.FieldValue("date",
Container)).ToString("dd-MM-yyyy") %></div></td>
</tr>
</table></td>
</tr>
</table></td>
<td width="335" align="left" valign="top"><table border="0"
cellspacing="0" cellpadding="3">
<tr>
<td align="left" valign="top"><img src='images/content/<%#
dsArticleRight.FieldValue("image", Container) %>' /></td>
<td align="left" valign="top"><table border="0"
cellspacing="0" cellpadding="0">
<tr>
<td class="heading_12px_02"><%#
dsArticleRight.FieldValue("title", Container) %></td>
</tr>
</table>
<table width="240" border="0" cellspacing="0"
cellpadding="1">
<tr>
<td class="text_11px_02"><div align="left"><%#
dsArticleRight.FieldValue("description", Container) %></div></td>
</tr>
</table>
<table width="220" border="0" cellpadding="2"
cellspacing="0">
<tr>
<td class="text_11px_02"><div align="right"><%#
DateTime.Parse(dsArticleRight.FieldValue("date",
Container)).ToString("dd-MM-yyyy") %></div></td>
</tr>
</table></td>
</tr>
</table></td>
</tr>
</table>
</div>
<div id="footer">
<table border="0" cellspacing="0" cellpadding="0">
<tr>
<td valign="middle" class="text_11px_03">© 2004 Jaqueline
Roxo Atelier, todos os direitos reservados </td>
</tr>
</table>
</div>
</div>
</body>
<!-- InstanceEnd --></html>
CODE END


Thank You,
Miguel
"Ken Cox [Microsoft MVP]" <BA************@sympatico.ca> wrote in message
news:e0**************@TK2MSFTNGP11.phx.gbl:
Hi Miguel,

The easiest way is to put the image inside a hyperlink control and set the

image name from the database. Check out the code below and let us know if
it
helps?

Ken
Microsoft MVP [ASP.NET]
<asp:DataList id="dlCollection" runat="server">
<ItemTemplate>

<asp:HyperLink id="HyperLink1" runat="server" NavigateUrl='<%#
"detail.aspx?number=" & DataBinder.Eval( Container.DataItem, "id") %>'>
<asp:Image id="Image1" runat="server" imageurl='<%#
DataBinder.Eval( Container.DataItem, "imageSmall") %>'></asp:Image>
</asp:HyperLink>
<asp:Label id="lblPrice" runat="server" ><%# DataBinder.Eval(
Container.DataItem, "price") %></asp:Label>
</ItemTemplate>
</asp:DataList>
Private Sub Page_Load _
(ByVal sender As System.Object, _
ByVal e As System.EventArgs) _
Handles MyBase.Load
dlCollection.DataSource = CreateDataSource()
dlCollection.DataBind()

End Sub
Function CreateDataSource() As DataTable
Dim dt As New DataTable
Dim dr As DataRow
dt.Columns.Add(New DataColumn _
("id", GetType(Int32)))
dt.Columns.Add(New DataColumn _
("imageSmall", GetType(String)))
dt.Columns.Add(New DataColumn _
("price", GetType(Double)))
dt.Columns.Add(New DataColumn _
("Boolean", GetType(Boolean)))
Dim i As Integer
For i = 0 To 8
dr = dt.NewRow()
dr(0) = i
dr(1) = "Item " + i.ToString()
dr(2) = 1.23 * (i + 1)
dr(3) = (i = 4)
dt.Rows.Add(dr)
Next i
Return dt
End Function 'CreateDataSource

"Miguel Dias Moura" <we****@27lamps.com> wrote in message
news:eK*************@TK2MSFTNGP11.phx.gbl...
Hello,

I created a datalist in an ASP.Net / VB page.
I display the image and price of a few products.

When a user clicks an image I want to load the page
"detail.aspx?number=id" and send the value of the "id" field of that
record as a URL parameter.

Can someone tell me how to do this.

The code I have is as follows:

<form runat="server">
<asp:DataList id="dlCollection"
runat="server"
RepeatColumns="4"
RepeatDirection="Horizontal"
RepeatLayout="Table"
DataSource="<%# dsCollection.DefaultView %>" >
<HeaderTemplate></HeaderTemplate>
<ItemTemplate>
<table cellspacing="4" cellpadding="4" align="center">
<tr>
<td align="center"><img
src="images/content/collection/<%# dsCollection.FieldValue("imageSmall",

Container) %>" /> </td>
</tr>
<tr>
<td align="center" valign="top"
class="heading_11px_01"><%# dsCollection.FieldValue("price", Container)
%>
</td>
</tr>
</table>
</ItemTemplate> </asp:DataList>
</form>

Thank You,
Miguel


Nov 18 '05 #4

P: n/a
Hello,

I just solved it.

<asp:HyperLink ID="hypDetails" Text="Detalhes"
NavigateUrl='<%#"detail.aspx?ID=" & DataBinder.Eval(Container.DataItem,
"ID")%>' Runat="server"></asp:HyperLink>

Thanks,
Miguel

"Ken Cox [Microsoft MVP]" <BA************@sympatico.ca> wrote in message
news:2A**********************************@microsof t.com:
Ouch. You seem to be using DreamWeaver which has its own way of doing
ASP.NET. You might be better off posting in a Macromedia newsgroup where

people understand DreamWeaver's controls.

"Miguel Dias Moura" wrote:

Hello,

I was trying your code but I wasn't able to make it work. This seems
really complicated and I am on this for days. Can you look at the code

of my page where everything is working but without the link and tell me

what should I do?

Here is the entire code (I know most of it is not important but I prefer

to send everything just to not miss something):

>> CODE START

<%@ Page Language="VB" ContentType="text/html"
ResponseEncoding="iso-8859-1" %>
<%@ Register TagPrefix="MM" Namespace="DreamweaverCtrls"

Assembly="DreamweaverCtrls,version=1.0.0.0,publicK eyToken=836f606ede05d46a,c
ulture=neutral"
%>
<MM:DataSet
id="dsArticleLeft"
runat="Server"
IsStoredProcedure="false"
ConnectionString='<%#

System.Configuration.ConfigurationSettings.AppSett ings("MM_CONNECTION_STRING
_connJaquelineRoxoAtelier")
%>'
DatabaseType='<%#

System.Configuration.ConfigurationSettings.AppSett ings("MM_CONNECTION_DATABA
SETYPE_connJaquelineRoxoAtelier")
%>'
CommandText='<%# "SELECT * FROM articleLeft" %>'
Debug="true"

</MM:DataSet>
<MM:DataSet
id="dsArticleRight"
runat="Server"
IsStoredProcedure="false"
ConnectionString='<%#

System.Configuration.ConfigurationSettings.AppSett ings("MM_CONNECTION_STRING
_connJaquelineRoxoAtelier")
%>'
DatabaseType='<%#

System.Configuration.ConfigurationSettings.AppSett ings("MM_CONNECTION_DATABA
SETYPE_connJaquelineRoxoAtelier")
%>'
CommandText='<%# "SELECT * FROM articleRight" %>'
Debug="true"

</MM:DataSet>
<MM:DataSet
id="dsCollection"
runat="Server"
IsStoredProcedure="false"
ConnectionString='<%#

System.Configuration.ConfigurationSettings.AppSett ings("MM_CONNECTION_STRING
_connJaquelineRoxoAtelier")
%>'
DatabaseType='<%#

System.Configuration.ConfigurationSettings.AppSett ings("MM_CONNECTION_DATABA
SETYPE_connJaquelineRoxoAtelier")
%>'
CommandText='<%# "SELECT * FROM collection ORDER BY reference DESC"
%>'
CurrentPage='<%# IIf((Request.QueryString("dsCollection_CurrentPage ") <>

Nothing), Request.QueryString("dsCollection_CurrentPage"), 0) %>'
PageSize="12"
Debug="true"

</MM:DataSet>
<MM:PageBind runat="server" PostBackBind="true" />
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"><!-- InstanceBegin
template="/Templates/basic.dwt.aspx" codeOutsideHTMLIsLocked="false"
-->
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"

/>
<!-- InstanceBeginEditable name="doctitle" -->
<title>Jaqueline Roxo - Atelier de Moda em Peles de Pelo</title>
<!-- InstanceEndEditable --><link href="css/styles.css" rel="stylesheet"

type="text/css" />
<script language="JavaScript" type="text/JavaScript">
<!--
function MM_swapImgRestore() { //v3.0
var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++)

x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0;
i<a.length; i++)
if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image;
d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
var p,i,x; if(!d) d=document;
if((p=n.indexOf("?"))>0&&parent.frames.length) {
d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++)
x=d.forms[i][n];
for(i=0;!x&&d.layers&&i<d.layers.length;i++)
x=MM_findObj(n,d.layers[i].document);
if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array;
for(i=0;i<(a.length-2);i+=3)
if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc)
x.oSrc=x.src; x.src=a[i+2];}
}

function P7_autoLayers() { //v1.4 by PVII
var

g,b,k,f,args=P7_autoLayers.arguments;a=parseInt(ar gs[0]);if(isNaN(a))a=0;
if(!document.p7setc){p7c=new Array();document.p7setc=true;for(var
u=0;u<10;u++){
p7c[u]=new

Array();}}for(k=0;k<p7c[a].length;k++){if((g=MM_findObj(p7c[a][k]))!=null){ > >
b=(document.layers)?g:g.style;b.visibility="hidden ";}}for(k=1;k<args.length;
k++){
if((g=MM_findObj(args[k]))!=null){b=(document.layers)?g:g.style;b.visibili ty
="visible";f=false;
for(var j=0;j<p7c[a].length;j++){if(args[k]==p7c[a][j]) {f=true;}}
if(!f){p7c[a][p7c[a].length++]=args[k];}}}
}
//-->
</script>
<meta name="title" content="Jaqueline Roxo - Atelier de Moda em Peles de

Pelo" />
<meta name="description" content="Atelier situado em Lisboa. Somos
especializados em peles de pelo, comercializamos, produzimos e
modificamos qualquer artigo em Pelo." />
<meta name="keywords" content="peles,pelo,moda,lisboa"/>
<meta name="language" content="Portuguese" />
<meta name="author" content="27 Lamps" />
<meta name="copyright" content="2004 Jaqueline Roxo Atelier" />
<meta name="reply-to" content="ge***@jaquelineroxoatelier.com" />
<meta name="document-classification" content="Fashion" />
<meta name="document-type" content="Web Page" />
<meta name="document-rating" content="Safe for Kids" />
<script language="JavaScript" type="text/JavaScript">
<!--
function MM_reloadPage(init) { //reloads the window if Nav4 resized
if (init==true) with (navigator) {if
((appName=="Netscape")&&(parseInt(appVersion)==4)) {
document.MM_pgW=innerWidth; document.MM_pgH=innerHeight;
onresize=MM_reloadPage; }}
else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH)

location.reload();
}
MM_reloadPage(true);

function P7_Snap() { //v2.65 by PVII
var

x,y,ox,bx,oy,p,tx,a,b,k,d,da,e,el,tw,q0,xx,yy,w1,p a='px',args=P7_Snap.argume
nts;a=parseInt(a);

if(document.layers||window.opera){pa='';}for(k=0;k <(args.length);k+=4){

if((g=MM_findObj(args[k]))!=null){if((el=MM_findObj(args[k+1]))!=null){
a=parseInt(args[k+2]);b=parseInt(args[k+3]);x=0;y=0;ox=0;oy=0;p="";tx=1;
da="document.all['"+args[k]+"']";if(document.getElementById){
d="document.getElementsByName('"+args[k]+"')[0]";if(!eval(d)){
d="document.getElementById('"+args[k]+"')";if(!eval(d)){d=da;}}
}else

if(document.all){d=da;}if(document.all||document.g etElementById){while(tx==1
){
p+=".offsetParent";if(eval(d+p)){x+=parseInt(eval( d+p+".offsetLeft"));y+=par
seInt(eval(d+p+".offsetTop"));
}else{tx=0;}}ox=parseInt(g.offsetLeft);oy=parseInt (g.offsetTop);tw=x+ox+y+oy
;
if(tw==0||(navigator.appVersion.indexOf("MSIE
4")>-1&&navigator.appVersion.indexOf("Mac")>-1)){
ox=0;oy=0;if(g.style.left){x=parseInt(g.style.left );y=parseInt(g.style.top);
}else{
w1=parseInt(el.style.width);bx=(a<0)?-5-w1:-10;a=(Math.abs(a)<1000)?0:a;b=(M
ath.abs(b)<1000)?0:b;
x=document.body.scrollLeft+event.clientX+bx;y=docu ment.body.scrollTop+event.
clientY;}}
}else if(document.layers){x=g.x;y=g.y;q0=document.layers ,dd="";for(var

s=0;s<q0.length;s++){
dd='document.'+q0[s].name;if(eval(dd+'.document.'+args[k])){x+=eval(dd+'.lef
t');y+=eval(dd+'.top');
break;}}}e=(document.layers)?el:el.style;xx=parseI nt(x+ox+a),yy=parseInt(y+o
y+b);
if(navigator.appVersion.indexOf("MSIE 5")>-1 &&
navigator.appVersion.indexOf("Mac")>-1){
xx+=parseInt(document.body.leftMargin);yy+=parseIn t(document.body.topMargin)
;}
e.left=xx+pa;e.top=yy+pa;}}}
}

function P7_hideEl(evt) { //v1.5 by PVII-www.projectseven.com
var b,r,m=false;if(document.layers){b=evt.target;if(b. p7aHide){
b.visibility="hidden";}else{routeEvent(evt);}
}else if(document.all&&!window.opera){b=event.srcElement ;while(b){
if(b.p7aHide){break;}b=b.parentElement;}if(!b.cont ains(event.toElement)){
b.style.visibility="hidden";}}else if(document.getElementById){
b=evt.currentTarget;r=evt.relatedTarget;while(r){i f(b==r){m=true;
break;}r=r.parentNode;}if(!m){b.style.visibility=" hidden";}}
}

function P7_autoHide() { //v1.5 by PVII-www.projectseven.com
var i,g;for(i=0;i<arguments.length;i++){
if((g=MM_findObj(arguments[i]))!=null){g.p7aHide=true;if(document.layers){
g.captureEvents(Event.MOUSEOUT);}g.onmouseout=P7_h ideEl;}}
}
//-->
</script>
<!-- InstanceBeginEditable name="head" --><!-- InstanceEndEditable -->
</head><body

onload="MM_preloadImages('images/design/button-coleccao-over.gif','images/bu
tton-servicos.over.gif','images/design/button-atelier-over.gif','images/desi
gn/button-luxus-over.gif','images/design/button-contactos-over.gif','images/
design/button-home-over.gif','images/design/button-servicos-over.gif');P7_au
toHide('submenu')">
<div id="submenu">
<table border="0" cellspacing="0" cellpadding="0">
<tr>
<td><a href="coleccao-filter.aspx?type=astracan"
onmouseout="MM_swapImgRestore()"

onmouseover="MM_swapImage('astracan','','images/design/button-astracan-over.
gif',1)"><img
src="images/design/button-astracan.gif" alt="astracan" name="astracan"

width="100" height="20" border="0" id="astracan" /></a></td>
</tr>
<tr>
<td><a href="coleccao-filter.aspx?type=castor"
onmouseout="MM_swapImgRestore()"

onmouseover="MM_swapImage('castor','','images/design/button-castor-over.gif'
,1)"><img
src="images/design/button-castor.gif" alt="castor" name="castor"
width="100" height="20" border="0" id="castor" /></a></td>
</tr>
<tr>
<td><a href="coleccao-filter.aspx?type=chinchila"
onmouseout="MM_swapImgRestore()"

onmouseover="MM_swapImage('chinchila','','images/design/button-chinchila-ove
r.gif',1)"><img
src="images/design/button-chinchila.gif" alt="chinchila"
name="chinchila" width="100" height="20" border="0" id="chinchila"
/></a></td>
</tr>
<tr>
<td><a href="coleccao-filter.aspx?type=lapin"
onmouseout="MM_swapImgRestore()"

onmouseover="MM_swapImage('lapin','','images/design/button-lapin-over.gif',1
)"><img
src="images/design/button-lapin.gif" alt="lapin" name="lapin"
width="100" height="20" border="0" id="lapin" /></a></td>
</tr>
<tr>
<td><a href="coleccao-filter.aspx?type=opossuma"
onmouseout="MM_swapImgRestore()"

onmouseover="MM_swapImage('opossuma','','images/design/button-opossuma-over.
gif',1)"><img
src="images/design/button-opossuma.gif" alt="opossuma" name="opossuma"

width="100" height="20" border="0" id="opossuma" /></a></td>
</tr>
<tr>
<td><a href="coleccao-filter.aspx?type=raposa"
onmouseout="MM_swapImgRestore()"

onmouseover="MM_swapImage('raposa','','images/design/button-raposa-over.gif'
,1)"><img
src="images/design/button-raposa.gif" alt="raposa" name="raposa"
width="100" height="20" border="0" id="raposa" /></a></td>
</tr>
<tr>
<td><a href="coleccao-filter.aspx?type=vison"
onmouseout="MM_swapImgRestore()"

onmouseover="MM_swapImage('vison','','images/design/button-vison-over.gif',1
)"><img
src="images/design/button-vison.gif" alt="vison" name="vison"
width="100" height="20" border="0" id="vison" /></a></td>
</tr>
</table>
</div>
<div id="wrapper">
<div id="header"><img src="images/design/logo-jratelier.jpg" width="680"

height="55" border="0" onmouseover="P7_autoLayers(0)" /></div>
<!-- InstanceBeginEditable name="menu" -->
<div id="menu"><a href="index.aspx" onmouseout="MM_swapImgRestore()"

onmouseover="MM_swapImage('home','','images/design/button-home-over.gif',1)"
<img

src="images/design/button-home.gif" alt="home" name="home" width="52"
height="20" border="0" id="home" onmouseover="P7_autoLayers(0)" /></a><a

href="coleccao.aspx"

onmouseover="P7_autoLayers(0,'submenu');MM_swapIma ge('coleccao','','images/d
esign/button-coleccao-over.gif',1);P7_Snap('coleccao','submenu',0,21)"
onmouseout="MM_swapImgRestore()"><img
src="images/design/button-coleccao-hit.gif" alt="colecção"
name="coleccao" width="72" height="20" border="0" id="coleccao" /></a><a

href="servicos.aspx"

onmouseover="MM_swapImage('servicos','','images/design/button-servicos-over.
gif',1);P7_autoLayers(0)"
onmouseout="MM_swapImgRestore()"><img
src="images/design/button-servicos.gif" alt="serviços" name="servicos"

width="70" height="20" border="0" id="servicos" /></a><a
href="atelier.aspx" onmouseout="MM_swapImgRestore()"

onmouseover="MM_swapImage('atelier','','images/design/button-atelier-over.gi
f',1)"><img
src="images/design/button-atelier.gif" alt="atelier" name="atelier"
width="59" height="20" border="0" id="atelier" /></a><a
href="luxus.aspx" onmouseout="MM_swapImgRestore()"

onmouseover="MM_swapImage('luxos','','images/design/button-luxus-over.gif',1
)"><img
src="images/design/button-luxus.gif" alt="luxo's" name="luxos"
width="54" height="20" border="0" id="luxos" /></a><a
href="contactos.aspx" onmouseout="MM_swapImgRestore()"

onmouseover="MM_swapImage('contactos','','images/design/button-contactos-ove
r.gif',1)"><img
src="images/design/button-contactos.gif" alt="contactos"
name="contactos" width="80" height="20" border="0" id="contactos"
/></a></div>
<!-- InstanceEndEditable --><!-- InstanceBeginEditable name="content"
-->
<div id="content">
<table width="675" border="0" cellpadding="4" cellspacing="2">
<tr>
<td align="center"><p><img
src="images/content/coleccao20042005.gif" width="321" height="25"
/></p></td>
</tr>
</table>
<table width="675" border="0" cellpadding="0" cellspacing="0">
<tr>
<td align="center" valign="top"><table width="660" border="0"
cellpadding="2" cellspacing="2" class="bottomBorder_CCCCCC">
<tr>
<td align="left"><div align="justify"><span
class="text_11px_01">Din√ɬĘmica e sens√ɬ*vel, esta
colecção define um estilo urbano mas elegante.
Prática para um uso diário e sofisticada para momentos
especiais. √É‚Äį a arte do camale√ɬ£o consoante a altura do dia:
inspiradora e audaz pela manhã, elegante e sofisticada á
noite as peles pela sua qualidade e desing ajustam-se perfeitamente a
qualquer ocasião.</span></div></td>
</tr>
</table> </td>
</tr>
</table>
<table border="0" cellpadding="2" cellspacing="5" align="center"
valign="top">
<tr>
<td align="left" valign="top"><p class="text_11px_01">
<form runat="server">
<asp:DataList id="dlCollection"
runat="server"
RepeatColumns="4"
RepeatDirection="Horizontal"
RepeatLayout="Table"
DataSource="<%# dsCollection.DefaultView %>" >
<HeaderTemplate></HeaderTemplate>
<ItemTemplate>
<table cellspacing="4" cellpadding="4" align="center">
<tr>
<td align="center"><img
src="images/content/collection/<%# dsCollection.FieldValue("imageSmall",

Container) %>" /> </td>
</tr>
<tr>
<td align="center" valign="top"
class="heading_11px_01"><%# dsCollection.FieldValue("price", Container)

%> </td>
</tr>
</table>
</ItemTemplate>
</asp:DataList>
</form>
</p></td>
</tr>
</table>
<table width="675" border="0" cellpadding="0" cellspacing="0"
class="heading_11px_01">
<tr>
<td align="center" valign="top"><table width="660" border="0"
cellpadding="4" cellspacing="2" class="topBorder_CCCCCC">
<tr>
<td align="center" valign="middle"><div
align="justify"></div>
<MM:If runat="server" Expression='<%#
(dsCollection.CurrentPage <> 0) %>'>
<ContentsTemplate><a href="<%#
Request.ServerVariables("SCRIPT_NAME") %>?dsCollection_currentPage=<%#

Math.Max(dsCollection.CurrentPage - 1, 0)
%>">Anterior</a></ContentsTemplate>
</MM:If>
| <%= IIf((dsCollection.RecordCount =
0), 0, (dsCollection.StartRecord + 1)) %>..<%= dsCollection.EndRecord
%> de <%= dsCollection.RecordCount %> |
<MM:If runat="server" Expression='<%#
(dsCollection.CurrentPage < dsCollection.LastPage) %>'>
<ContentsTemplate><a href="<%#
Request.ServerVariables("SCRIPT_NAME") %>?dsCollection_currentPage=<%#

Math.Min(dsCollection.CurrentPage + 1, dsCollection.LastPage)
%>">Seguinte</a></ContentsTemplate>
</MM:If></td>
</tr>
</table></td>
</tr>
</table>
</div>
<!-- InstanceEndEditable -->
<div id="articles">
<table width="670px" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="335" align="left" valign="top"><table border="0"
cellspacing="0" cellpadding="3">
<tr>
<td align="left" valign="top"><img src='images/content/<%#
dsArticleLeft.FieldValue("image", Container) %>' /></td>
<td align="left" valign="top"><table border="0"
cellspacing="0" cellpadding="0">
<tr>
<td class="heading_12px_02"><%#
dsArticleLeft.FieldValue("title", Container) %></td>
</tr>
</table>
<table width="240" border="0" cellspacing="0"
cellpadding="1">
<tr>
<td class="text_11px_02"><div align="left"><%#
dsArticleLeft.FieldValue("description", Container) %></div></td>
</tr>
</table>
<table width="220" border="0" cellpadding="2"
cellspacing="0">
<tr>
<td class="text_11px_02"><div align="right"><%#
DateTime.Parse(dsArticleLeft.FieldValue("date",
Container)).ToString("dd-MM-yyyy") %></div></td>
</tr>
</table></td>
</tr>
</table></td>
<td width="335" align="left" valign="top"><table border="0"
cellspacing="0" cellpadding="3">
<tr>
<td align="left" valign="top"><img src='images/content/<%#
dsArticleRight.FieldValue("image", Container) %>' /></td>
<td align="left" valign="top"><table border="0"
cellspacing="0" cellpadding="0">
<tr>
<td class="heading_12px_02"><%#
dsArticleRight.FieldValue("title", Container) %></td>
</tr>
</table>
<table width="240" border="0" cellspacing="0"
cellpadding="1">
<tr>
<td class="text_11px_02"><div align="left"><%#
dsArticleRight.FieldValue("description", Container) %></div></td>
</tr>
</table>
<table width="220" border="0" cellpadding="2"
cellspacing="0">
<tr>
<td class="text_11px_02"><div align="right"><%#
DateTime.Parse(dsArticleRight.FieldValue("date",
Container)).ToString("dd-MM-yyyy") %></div></td>
</tr>
</table></td>
</tr>
</table></td>
</tr>
</table>
</div>
<div id="footer">
<table border="0" cellspacing="0" cellpadding="0">
<tr>
<td valign="middle" class="text_11px_03">√ā¬© 2004 Jaqueline
Roxo Atelier, todos os direitos reservados </td>
</tr>
</table>
</div>
</div>
</body>
<!-- InstanceEnd --></html>

CODE END

Thank You,
Miguel
"Ken Cox [Microsoft MVP]" <BA************@sympatico.ca> wrote in message

news:e0**************@TK2MSFTNGP11.phx.gbl:

Hi Miguel,

The easiest way is to put the image inside a hyperlink control and set
the

image name from the database. Check out the code below and let us know
if
it
helps?

Ken
Microsoft MVP [ASP.NET]
<asp:DataList id="dlCollection" runat="server">
<ItemTemplate>

<asp:HyperLink id="HyperLink1" runat="server" NavigateUrl='<%#
"detail.aspx?number=" & DataBinder.Eval( Container.DataItem, "id")
%>'>
<asp:Image id="Image1" runat="server" imageurl='<%#
DataBinder.Eval( Container.DataItem, "imageSmall") %>'></asp:Image>
</asp:HyperLink>
<asp:Label id="lblPrice" runat="server" ><%# DataBinder.Eval(
Container.DataItem, "price") %></asp:Label>
</ItemTemplate>
</asp:DataList>
Private Sub Page_Load _
(ByVal sender As System.Object, _
ByVal e As System.EventArgs) _
Handles MyBase.Load
dlCollection.DataSource = CreateDataSource()
dlCollection.DataBind()

End Sub
Function CreateDataSource() As DataTable
Dim dt As New DataTable
Dim dr As DataRow
dt.Columns.Add(New DataColumn _
("id", GetType(Int32)))
dt.Columns.Add(New DataColumn _
("imageSmall", GetType(String)))
dt.Columns.Add(New DataColumn _
("price", GetType(Double)))
dt.Columns.Add(New DataColumn _
("Boolean", GetType(Boolean)))
Dim i As Integer
For i = 0 To 8
dr = dt.NewRow()
dr(0) = i
dr(1) = "Item " + i.ToString()
dr(2) = 1.23 * (i + 1)
dr(3) = (i = 4)
dt.Rows.Add(dr)
Next i
Return dt
End Function 'CreateDataSource

"Miguel Dias Moura" <we****@27lamps.com> wrote in message
news:eK*************@TK2MSFTNGP11.phx.gbl...
Hello,
>
> I created a datalist in an ASP.Net / VB page.
> I display the image and price of a few products.
>
> When a user clicks an image I want to load the page
> "detail.aspx?number=id" and send the value of the "id" field of
> that
> record as a URL parameter.
>
> Can someone tell me how to do this.
>
> The code I have is as follows:
>
> <form runat="server">
> <asp:DataList id="dlCollection"
> runat="server"
> RepeatColumns="4"
> RepeatDirection="Horizontal"
> RepeatLayout="Table"
> DataSource="<%# dsCollection.DefaultView %>" >
> <HeaderTemplate></HeaderTemplate>
> <ItemTemplate>
> <table cellspacing="4" cellpadding="4"
> align="center">
> <tr>
> <td align="center"><img
> src="images/content/collection/<%#
> dsCollection.FieldValue("imageSmall",
>
> Container) %>" /> </td>
> </tr>
> <tr>
> <td align="center" valign="top"
> class="heading_11px_01"><%# dsCollection.FieldValue("price",
> Container)
> %>
> </td>
> </tr>
> </table>
> </ItemTemplate> </asp:DataList>
> </form>
>
> Thank You,
> Miguel
>



Nov 18 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.