Hi,
I'm really struggling with creating an if statement with the content of a data repeater.
I'm looking for somthing along the following lines...
<%IF Container.DataItem( "fldExtraImage1" ) is not dbnull THEN
<img src="images/Extras/<%# Container.DataItem( "fldExtraImage1" ) %>" alt="<%# Container.DataItem( "fldExtraTitle1" ) %>">
ELSE IF Container.DataItem( "fldExtraImage2" ) is not dbnull THEN
<img src="images/Extras/<%# Container.DataItem( "fldExtraImage2" ) %>" alt="<%# Container.DataItem( "fldExtraTitle2" ) %>">
Below is the code that I need to apply it to...
<%@ Import Namespace="System.Data.SqlClient" %>
<Script Runat="Server">
Sub Page_Load
Dim conPubs As SqlConnection
Dim cmdSelect As SqlCommand
Dim dtrAuthors As SqlDataReader
' Retrieve records from database
conPubs = New SqlConnection( "Server=xyz" )
cmdSelect = New SqlCommand( "SELECT tblMain.*, tblRetailer.*, tblItem.*, tblItemVersion.fldItemVersion FROM tblMain INNER JOIN tblRetailer ON tblMain.fldRetailerID = tblRetailer.fldRetailerID INNER JOIN tblItem ON tblMain.fldItemID = tblItem.fldItemID INNER JOIN tblItemVersion ON tblItem.fldItemVersionID = tblItemVersion.fldItemVersionID WHERE (tblItem.fldItemTitle LIKE '3' and tblMain.fldNotAvailable is null)", conPubs )
conPubs.Open()
dtrAuthors = cmdSelect.ExecuteReader()
' Bind to Repeater
rptAuthors.DataSource = dtrAuthors
rptAuthors.DataBind()
dtrAuthors.Close()
conPubs.Close()
End Sub
</Script>
<html>
<head><title>RepeaterTable.aspx</title></head>
<body>
<form Runat="Server">
<asp:Repeater
ID="rptAuthors"
Runat="Server">
<HeaderTemplate>
<table border=1 cellpadding=4>
<tr bgcolor="#eeeeee">
<th>Retailer</th>
<th>Items</th>
<th>Price</th>
</tr>
</HeaderTemplate>
<ItemTemplate>
<img src="images/Extras/<%# Container.DataItem( "fldExtraImage1" ) %>" alt="<%# Container.DataItem( "fldExtraTitle1" ) %>">
<img src="images/Extras/<%# Container.DataItem( "fldExtraImage2" ) %>" alt="<%# Container.DataItem( "fldExtraTitle2" ) %>">
<img src="images/Extras/<%# Container.DataItem( "fldExtraImage3" ) %>" alt="<%# Container.DataItem( "fldExtraTitle3" ) %>">
<img src="images/Extras/<%# Container.DataItem( "fldExtraImage4" ) %>" alt="<%# Container.DataItem( "fldExtraTitle4" ) %>">
<img src="images/Extras/<%# Container.DataItem( "fldExtraImage5" ) %>" alt="<%# Container.DataItem( "fldExtraTitle5" ) %>">
</ItemTemplate>
<FooterTemplate>
</table>
</FooterTemplate>
</asp:Repeater>
</form>
</body>
</html>
Any help on this would be greatly appreciated.
Squirell