When I run this locally without trying to display an image it runs fine. The problem is displaying the image in the detail.aspx page. Below I entered what I thought would work. Can anyone take a good hard look at this and help get me on the right track.
At the very bottom I'm using the following to pull the image:
<IMG SRC='images/<%# Container.DataItem("ImageLabel") %>' Border="0"
Any opinions would be greatly appreciated.
Thank You.
I have included before detail.aspx and testad.ascx below.
===================================================
DETAIL.aspx PAGE...
<%@dotnet.itags.org. Register TagPrefix="ASPFD" TagName="Header" src="http://pics.10026.com/?src=header.ascx" %>
<%@dotnet.itags.org. Register TagPrefix="ASPFD" TagName="TestAd" src="http://pics.10026.com/?src=Testad.ascx" %>
<HTML>
<script runat="server">
Sub Page_Load(Sender As Object, E As EventArgs)
If Not IsPostBack Then
Dim AdNumSent As Integer
If Trim(Request.QueryString("AdNum")) = "" Then
Response.Redirect("default.aspx")
End If
Header.AddPageName("Ad Detail")
AdNumSent = Trim(Request.QueryString("AdNum"))
TestAd.GetAd(AdNumSent)
End If
End Sub
</script>
<body vlink="red">
<form runat="server">
<aspfd:header id="Header" runat="server" />
<aspfd:testad id="testAd" runat="server" />
</form>
</body>
</HTML
===================================================
TESTAD.ascx Page...
<%@dotnet.itags.org. Import Namespace="System.Data" %>
<%@dotnet.itags.org. Import Namespace="System.Data.OleDb" %>
<script runat="server">
Dim ConnectString, SelectStatement As String
Dim Connect As OleDbConnection = New OleDbConnection
Dim Adapter As OleDbDataAdapter = New OleDbDataAdapter
Dim TestCB As OleDbCommandBuilder
Dim TestDS As DataSet = New DataSet
Dim Row As DataRow
Public AdNum As Integer
Public Title As String
Public Description As String
Public Category As String
Public Price As String
Public Phone As String
Public Email As String
Public State As String
Public Posted As Date
Public Password As String
Public Image As String
Public HasErrors As Boolean
Public RowError As String
Sub GetAd(AdNumSent As Integer)
SelectStatement = "Select * From Ads Where AdNum=" & AdNumSent
ConnectString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & server.mappath("Testdb.mdb") & ";"
Connect.ConnectionString = ConnectString
Adapter.SelectCommand = new OleDbCommand(SelectStatement, Connect)
Adapter.Fill(TestDS,"Ads")
TestCB = New OleDbCommandBuilder(Adapter)
If TestDS.Tables("Ads").Rows.Count > 0 Then
Row = TestDS.Tables("Ads").Rows(0)
AdNum = Row.Item("AdNum")
Title = Row.Item("Title")
Description = Row.Item("Description")
Category = Row.Item("Category")
Price = Row.Item("Price")
Phone = Row.Item("Phone")
Email = Row.Item("Email")
State = Row.Item("State")
Posted = Row.Item("Posted")
Password = Row.Item("Password")
Image = Row.Item("Image")
TitleLabel.Text = Title
DescriptionLabel.Text = Description
PriceLabel.Text = Price
PhoneLabel.Text = Phone
EmailLink.Text = Email
EmailLink.NavigateURL = "mailto:" & Email
StateLabel.Text = State
PostedLabel.Text = Posted
ImageLabel.Text = Image
End If
PostErrors
End Sub
Sub PlaceAd
Row = TestDS.Tables("Ads").NewRow
CopyToDS
Row.Item("Posted") = CDate(Today)
TestDS.Tables("Ads").Rows.Add(Row)
Adapter.Update(TestDS, "Ads")
PostErrors
End Sub
Sub EditAd
CopyToDS
Adapter.Update(TestDS, "Ads")
PostErrors
End Sub
Sub DeleteAd
TestDS.Tables("Ads").Rows(0).Delete
Adapter.Update(TestDS, "Ads")
PostErrors
End Sub
' Copy the values in the properties of this
' control in the TestDS
Private Sub CopyToDS
Row.Item("Title") = Title
Row.Item("Description") = Description
Row.Item("Category") = Category
Row.Item("Price") = CSng(Price)
Row.Item("Phone") = Phone
Row.Item("Email") = Email
Row.Item("State") = State
Row.Item("Password") = Password
Row.Item("Image") = Image
End Sub
Private Sub PostErrors
HasErrors = TestDS.HasErrors
If HasErrors Then
RowError = TestDS.Tables("Ads").Rows(0).RowError
End If
End Sub
</script>
<asp:datalist id="DataList1" runat="server"></asp:datalist>
<TABLE id="Table1" cellSpacing="0" cellPadding="2" width="100%" bgColor="lime" border="1">
<tr>
<td bgColor="yellow" colSpan="2"><asp:label id="TitleLabel" runat="server" font-bold="true" font-size="12 pt"></asp:label></td>
</tr>
<tr>
<td vAlign="top" width="25%">Description:</td>
<td><asp:label id="DescriptionLabel" runat="server" font-bold="true" font-size="12 pt"></asp:label></td>
</tr>
<tr>
<td width="25%">Price:</td>
<td>$<asp:label id="PriceLabel" runat="server" font-bold="true" font-size="12 pt"></asp:label>
</td>
</tr>
<tr>
<td width="25%">Phone:</td>
<td><asp:label id="PhoneLabel" runat="server" font-bold="true" font-size="12 pt"></asp:label></td>
</tr>
<tr>
<td width="25%">Email:</td>
<td><asp:hyperlink id="EmailLink" runat="server" font-bold="true" font-size="12 pt"></asp:hyperlink></td>
</tr>
<tr>
<td width="25%">Location:</td>
<td><asp:label id="StateLabel" runat="server" font-bold="true" font-size="12 pt"></asp:label></td>
</tr>
<tr>
<td width="25%">Posted Date:</td>
<td><asp:label id="PostedLabel" runat="server" font-bold="true" font-size="12 pt"></asp:label></td>
</tr>
<tr>
<td width="25%">Image:</td>
<td><IMG SRC='images/<%# Container.DataItem("ImageLabel") %>' Border="0"></td>
</tr>
</TABLE>Anyone have any idea??????
You forgot to DataBind()
Bleroy,
If I run the code without trying to pull an image it works and I didn't Data Bind() it. When an image is add into the mix do you have to Data Bind()? Is an image handled different?
Thanks.
A help would be apprieciated. This is really frustrating me. grrrr
What does ImageLabel contain? What do you see when you look at the client-side HTML?
0 comments:
Post a Comment