Here's what I'm trying to do:
Display a list (lastname), (firstname) from a database. If that person has a weblink, I want to make their name a weblink, for example,
<a href="weblinkexists">(last
name), (firstname) </a>
<a href="weblinkexists">(last
name), (firstname) </a>
(lastname), (firstname) -- this person has no weblink, just their static name shows
<a href="weblinkexists">(last
name), (firstname) </a>
<a href="weblinkexists">(last
name), (firstname) </a>
HERE'S MY CODE SNIPPET:
Dim i_website1
Sub Page_Load(sender as Object, e as EventArgs)
call openDB()
dim strSQL="Select * from jbi_artist WHERE director_group='flute' ORDER BY director_lastname"
Dim ds2 As New DataSet()
dim mycommand2 as new MySqlDataAdapter(strSQL, connTemp)
mycommand2.Fill(ds2, "cur_data2")
flute.DataSource = ds2
flute.DataBind()
i_website1 = ds2.Tables("cur_data2").Ro
ws(0)("dir
ector_webs
ite")
call CloseDB()
End Sub
AND HERE"S MY DATALIST ON THE PAGE:
<asp:DataList ID="flute" GridLines="None" HorizontalAlign="Left" CellPadding="0" ItemStyle-VerticalAlign="T
OP" CellSpacing="0" RepeatDirection="Vertical"
RepeatLayout="Table" RepeatColumns="1" ShowBorder="False" Width="100%" runat="server" >
<ItemTemplate>
<% IF i_website1 <> "" THEN
%>
<a href="<%# DataBinder.Eval(Container.
DataItem, "director_website") %>"> <%# DataBinder.Eval(Container.
DataItem, "director_lastname") %>, <%# DataBinder.Eval(Container.
DataItem, "director_firstname") %></a><br />
<% ELSE %>
<%# DataBinder.Eval(Container.
DataItem, "director_lastname") %>, <%# DataBinder.Eval(Container.
DataItem, "director_firstname") %><br />
<% END IF %>
</ItemTemplate>
</asp:DataList>
No matter how I flip things around, either everyone has a link or no one has a link.
For example,
<a href="weblinkexists">LastN
ame, FirstName</a> (actually has a website so the link is correct)
<a href="mydomain">LastName, FirstName</a> (has no website, but it take the a href anyway
<a href="weblinkexists">Last,
First </a>(actually has a website so the link is correct)
I've tried making the field (NULL), empty, etc.
I think I need to use "count" to go through each row and see if that value is NULL, but my attempts with that have thrown errors.
Thanks for any assistance!
Start Free Trial