I need a way to write a certain line to the itemtemplate inside the datalist control if the current row being written is 1. This is what I have:

<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td>

<asp:DataList ID="MyDataList" RepeatColumns="2" runat="server">
<ItemTemplate>

<a href="/Vegas2/Celebrities/celebritybio.aspx?CelebID=<%# DataBinder.Eval(
Container.DataItem, "CelebID") %>">
<table border="0" cellspacing="0" cellpadding="0">
<tr>
<td>
<table class="handlink" border="0" cellspacing="0" cellpadding="0"
 onMouseOver="c2On(this);" onMouseOut="c2Out(this);"
  onClick="window.location='/Vegas2/Celebrities/celebritybio.asp?CelebID=
  <%# DataBinder.Eval(Container.DataItem, "CelebID") %>'">


'[if this is the first row, write the following:
'<tr>
'<td colspan="4"><img src="/Vegas2/images/2w12.gif" alt="" /></td>
'</tr>
'end the if]


<tr>
<td height="4" colspan="4"></td>
</tr>
<tr>
<td width="10"></td>
<td width="100" valign="center"><img src="<%# DataBinder.Eval(Container.DataItem,
 "CelebPicSm") %>" alt="" /></td>
<td width="10"></td>
<td width="140"><table border="0" cellpadding="0" cellspacing="0">
<tr>
<td height="4"></td>
</tr>
<tr>
<td class="smalltxt">Name:&nbsp;&nbsp;<strong><%# DataBinder.Eval(Container.DataItem,
 "CelebName") %></strong></td>
</tr>
<tr>
<td class="smalltxt">DOB:&nbsp;&nbsp;<%# String.Format("{0:d}",(DataBinder.Eval(
Container.DataItem, "DateofBirth"))) %></td>
</tr>
<tr>
<td class="smalltxt">
Age:&nbsp;&nbsp;<%# Age((String.Format("{0:d}",(DataBinder.Eval(Container.DataItem,
 "DateofBirth")))),(DataBinder.Eval(Container.DataItem, "Dead"))) %> </td>
</tr>
<tr>
<td class="smalltxt">Career:&nbsp;&nbsp;<%# DataBinder.Eval(Container.DataItem,
 "Career") %></td>
</tr>
</table></td>
</tr>
<tr>
<td colspan="4" height="4"></td>
</tr>
<tr>
<td colspan="4"><img src="/Vegas2/images/2w12.gif" alt="" style="margin-top:3px;" /></td>
</tr>
</table>
</td>
<td width="4"></td>
</tr>
</table>
</a>
</ItemTemplate>
</asp:DataList>

</td>
</tr>
<tr>
<td height="8"></td>
</tr>
</table>

I need to write an image to complete the surrounding box. If I have it write both at the top, and bottom, the separator becomes thick, and does not look nice. The image needs to be written above where it is said, but only if it is the first record being written. I cannot deal with the HeaderTemplate as some records will only return one result. If I use the header template to add the image to both columns and only one record is displayed viewing only one column, obviously it looks off. Thanks.

I still need help on this.

I need a hint on what to do, if anyone can help. I need to make a function or if statement for a DataList that basically says:

IF this is first row THEN
write your image
END IF

BUT it also needs to work on both columns. I'd use the headertemplate but sometimes there's only one record, sometimes more. Should I use a function to see if there is only one record, and if so write to the header accordingly to fit one header? hmm.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.