•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the ASP.NET section within the Web Development category of DaniWeb, a massive community of 456,527 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,801 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our ASP.NET advertiser: Lunarpages ASP Web Hosting
Views: 1691 | Replies: 1
![]() |
•
•
Join Date: Sep 2007
Posts: 1,058
Reputation:
Rep Power: 4
Solved Threads: 61
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:
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.
<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: <strong><%# DataBinder.Eval(Container.DataItem,
"CelebName") %></strong></td>
</tr>
<tr>
<td class="smalltxt">DOB: <%# String.Format("{0:d}",(DataBinder.Eval(
Container.DataItem, "DateofBirth"))) %></td>
</tr>
<tr>
<td class="smalltxt">
Age: <%# Age((String.Format("{0:d}",(DataBinder.Eval(Container.DataItem,
"DateofBirth")))),(DataBinder.Eval(Container.DataItem, "Dead"))) %> </td>
</tr>
<tr>
<td class="smalltxt">Career: <%# 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.
•
•
Join Date: Sep 2007
Posts: 1,058
Reputation:
Rep Power: 4
Solved Threads: 61
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.
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.
![]() |
•
•
•
•
•
•
•
•
DaniWeb ASP.NET Marketplace
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
- Repeater,datalist, datagrid (ASP.NET)
- Configuration Error (ASP.NET)
- asp:repeater in a form? (ASP.NET)
- Using the Datalist Control as a Menu (ASP.NET)
- dynamic tables (ASP.NET)
- Nest Datagrids (ASP.NET)
Other Threads in the ASP.NET Forum
- Previous Thread: Age Function Help
- Next Thread: example of editing in DataGrid and Default Paging



Linear Mode