hyper link image prob

mars

Member
Joined
Jun 19, 2006
Messages
13
Programming Experience
1-3
hi im new in asp.net
i want to show images with every record and hyper link on that
i wrot code but images are'nt comming.

HTML:
<%@ Page Language="VB" %>
<%@ import Namespace="System.Data.OleDb" %>
<script runat="server">
'<a href=pdetails.aspx?id=" & drprod.GetInt32(3).ToString() & "<img border=0 height=90 width=90 src=" & Fname & "></a>"
 
Sub page_load(source as Object, e As EventArgs)
dim strDir,connStr as string
strDir = System.AppDomain.CurrentDomain.BaseDirectory() & "db/shopingcart.mdb"
'lblmain.text = strdir
connStr = "Provider=Microsoft.Jet.OLEDB.4.0;data Source=" & strDir & ""
dim cnAccess as New OleDbConnection(connStr)
cnAccess.Open()
dim sSelectSQL as string
'Make the select statement
sSelectSQL = "select top 4 * from product"
'Make the OleDbCommand object
dim cmdSelect as New OleDbCommand(sSelectSQL,cnAccess)
' This query should return an OleDbDataReader so we use the ExecuteReader method
dim drProd as OleDbDataReader
drprod = cmdSelect.ExecuteReader()
dim strMain as string
strMain = "<br><br><table width=60% border=0 cellspacing=4 cellpadding=4 align=center>"
strMain = strMain & "<tr>"
dim strPath
strPath = "images/"
'this will return the web site directory name
lblmain.text = System.AppDomain.CurrentDomain.BaseDirectory() & "images/"
dim count,tot as integer
count = 1
tot = 0
while drProd.read
dim Fname = "images/" & drprod.getstring(5)
strMain = strMain & "<td align=center>"
'strMain = strMain & "<asp:HyperLink id=HyperLink" & tot & " runat=server ImageUrl=" & fname & " NavigateUrl=default.aspx?id=2></asp:HyperLink>"
StrMain = strmain & "<asp:HyperLink id=""HyperLink" & tot & " runat=""server"" NavigateUrl=""default.aspx"" ImageUrl=""Images/bear.jpg"">HyperLink</asp:HyperLink>"
'strMain = "<img border=0 height=90 width=90 src=" & Fname & ">"
lblfname.text = fname
'<asp:HyperLink id=HyperLink1 runat=server NavigateUrl=pdetails.asp><img border=0 height=90 width=90 src=" & Fname & "></asp:HyperLink>"
strMain = strMain & "<br><br>" & mid(drprod.getstring(1),1,10) & "...."
strMain = strMain & "<br><br>" & drprod.GetInt32(3).ToString() & "</td>"
if count = 2 then
strMain = strMain & "</tr><tr>"
count = 0
end if
count = count + 1
tot = tot + 1
End While
strMain = strMain & "</tr></table>"
lblmain.text = strMain
End Sub
</script>
<html>
<head>
<title>e-Greeting</title>
<link href="images/mycss.css" type="text/css" rel="stylesheet" />
</head>
<body leftmargin="0" topmargin="0">
<table class="" width="750" align="center" border="0" s="s">
<tbody>
<tr>
<td colspan="3">
<!-- #include file="header.html" --></td>
</tr>
<tr valign="top">
<td width="20%" background="images/topnavbg.jpg">
<!-- #include file="leftnavi.html" --></td>
<td valign="center" width="60%">
<!-- code will come here --><asp:Label id="lblmain" runat="server"></asp:Label>
<!-- code will come here --></td>
<td valign="top" width="20%">
cartcode will come here</td>
</tr>
<tr>
<td colspan="3">
<asp:Label id="lblfname" runat="server"></asp:Label>
<!-- #include file="footer.html" --></td>
</tr>
</tbody>
</table>
</body>
</html>
if any one know the solution please tell me
thanx
 
Last edited by a moderator:
If I can remember VS2003 correctly, you're going about this all wrong. Well not wrong but you're not utilizing ASP.NET's full capabilities.
You should probably use a repeator control (or another list control, I can't remember what was included in 2003). There are many tutorials concerning the repeator. Perhaps you could get started with that and post back any questions that may arise.
 
Back
Top