Need help with IF, Then scenario

indyB

Member
Joined
Mar 13, 2003
Messages
15
Ive got a repeater table which outputs a list of titles and pdf file names from a table in our db. Currently the titles link to a detail page pertaining to specifics about that title, stored in the db, and the pdf file names link pdf documents for those titles that do have a pdf. Some titles have info in the db, others have info in a pdf, none have both. This works fine, exept that the titles which have pdfs still show up as links, but when clicked, no details show up on the detail page, as expected. So, I need to make the titles only link to the detail page if there is not a pdf for that title. The db stores the pdf file name for those which do have pdfs.

I think this could easily be done w/ an if / then type of statement...I just dont know how to do that. Can anyone help me out here. I kind of need it spelled out as Im new to this concept in .net.

Thanks in advance for any assistance!

Heres the code ---

<%@ Page Language="vb" %>

<%@ import Namespace="System.Data" %>

<%@ import Namespace="System.Data.SqlClient" %>

<script runat="server">



Sub Page_Load(Sender As Object, E As EventArgs)



Dim DS As DataSet

Dim MyConnection As SqlConnection

Dim MyCommand As SqlDataAdapter



MyConnection = New SqlConnection("server=localhost; user id=sa; password=; Database = IAR")

MyCommand = New SqlDataAdapter("SELECT docTitle, pdfFileName, id FROM leadership_general ORDER BY docTitle ASC", MyConnection)



DS = New DataSet()

MyCommand.Fill(DS, "leadership_general")



MyRepeater.DataSource = DS.Tables("leadership_general").DefaultView

MyRepeater.DataBind()

End Sub



Sub MyRepeater_ItemCommand(source As Object, e As RepeaterCommandEventArgs)



End Sub



</script>

<html>

<head>

</head>

<body leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">

<p>

<a href="../">Leadership Home</a>

</p>

<p>

General Information&nbsp;<br />

<br />

<ASP:Repeater id="MyRepeater" runat="server" OnItemCommand="MyRepeater_ItemCommand">

<HeaderTemplate>

<table width="100%">

<tr style="background-color:006699; font: 8pt arial; color: white">

<th>

Title

</th>

<th>

PDF File Name

</th>

</tr>

</HeaderTemplate>

<ItemTemplate>

<tr style="background-color:efefef">

<td>

<asp:HyperLink NavigateUrl=<%# "genInfoDocs.aspx?id=" & DataBinder.Eval(Container.DataItem, "id") %> runat="server" ID="titleLink" NAME="titleLink" Text=<%# DataBinder.Eval(Container.DataItem, "docTitle") %> />

</td>

<td>

<asp:HyperLink NavigateUrl=<%# "docs/" & DataBinder.Eval(Container.DataItem, "pdfFileName") %> runat="server" ID="pdfLink" NAME="pdfLink" Text=<%# DataBinder.Eval(Container.DataItem, "pdfFileName") %> />

</td>

</tr>

</ItemTemplate>

<FooterTemplate>

</table>

</FooterTemplate>

</ASP:Repeater>

</p>

</body>

</html>
 
Back
Top