•
•
•
•
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,519 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,806 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: 2003 | Replies: 2 | Solved
![]() |
•
•
Join Date: Sep 2007
Posts: 1,058
Reputation:
Rep Power: 4
Solved Threads: 61
Since I have not found a way to add values into the header of my repeater, I was forced to use literals or a new DataList/Repeater.
I only need to display a name and an ID in a header for a datalist, but cannot seem to make this happen! So I resorted to two options below and would like to know which one would be a better choice. Please take into consideration the performance and stability issues. Below are the two codes. One uses one Repeater and the other uses 5 literals with visibility. I have separated the sections for you with "---------------".
Unless someone knows how to access labels/literals or databind the HeaderTemplate in a repeater, this is what I have to do. Thanks!
This set are the Literals (5 literals total set with visibility on page_load):
or Below (Repeater):
I only need to display a name and an ID in a header for a datalist, but cannot seem to make this happen! So I resorted to two options below and would like to know which one would be a better choice. Please take into consideration the performance and stability issues. Below are the two codes. One uses one Repeater and the other uses 5 literals with visibility. I have separated the sections for you with "---------------".
Unless someone knows how to access labels/literals or databind the HeaderTemplate in a repeater, this is what I have to do. Thanks!
This set are the Literals (5 literals total set with visibility on page_load):
-------------------------------------------------------------------------------------------------------------------------------- <asp:Repeater ID="CelebStories" runat="server"> <ItemTemplate> <tr> <td colspan="2"><img width="525" src="/Vegas2/images/2w.gif" alt="" /></td> </tr> <tr> <td height="13" colspan="2"></td> </tr> <tr> <td colspan="2"> <table width="100%" border="0" cellspacing="0" cellpadding="0"> <tr> <td width="90%"><strong><%# DataBinder.Eval(Container.DataItem, "StoryTitle") %></strong></td> <td width="10%" nowrap="nowrap" align="right"><div style="margin-right:20px;"><font color="#666666">Category: <%# DataBinder.Eval(Container.DataItem, "Category") %></font></div></td> </tr> <tr> <td colspan="2"><div style="margin: 10px 10px 10px 10px;"><%# DataBinder.Eval(Container.DataItem, "Story") %> <font size="2" face="Verdana" color="#666666">... [<a href="/Vegas2/Stories/stories.aspx?StoryID=<%# DataBinder.Eval(Container.DataItem, "StoryID") %>">Full Story</a>]</div></td> </tr> <tr> <td colspan="2"> <table border="0" cellpadding="0" cellspacing="0" width="100%"> <tr> <td width="30%" class="subinfo">Posted By: <a href="/Vegas2/Users/profile.aspx?uaid=<%# DataBinder.Eval(Container.DataItem, "UserID") %>"><%# DataBinder.Eval(Container.DataItem, ("UserName")) %></a></td> <td width="30%" class="subinfo">Date Posted: <%# String.Format("{0:d}", DataBinder.Eval(Container.DataItem, "DateCreated")) %></td> <td width="30%" class="subinfo">Story Views: <%# FormatNumber(DataBinder.Eval(Container.DataItem, "StoryViews"),0) %></td> <td width="10%" class="subinfo"><%# DataBinder.Eval(Container.DataItem, "PosNeg") %></td> </tr> </table> </td> </tr> </table> </td> </tr> </ItemTemplate> <SeparatorTemplate> <tr> <td height="13" colspan="2"></td> </tr> <tr> <td colspan="2"><img width="525" src="/Vegas2/images/2w.gif" alt="" /></td> </tr> <tr> <td height="2" colspan="2"></td> </tr> </SeparatorTemplate> <FooterTemplate> <tr> <td height="13" colspan="2"></td> </tr> <tr> <td colspan="2"><img width="525" src="/Vegas2/images/2w.gif" alt="" /></td> </tr> <tr> <td height="4" colspan="2"></td> </tr> <tr> <td colspan="2"><img width="525" src="/Vegas2/images/2w.gif" alt="" /></td> </tr> <tr> <td height="10" colspan="2"></td> </tr> </table> </FooterTemplate> </asp:Repeater><asp:Literal id="lblStoryHeader1" visible="false" runat="server"> <table width="525" border="0" cellspacing="0" cellpadding="0"> <tr> <td colspan="2"><img width="525" src="/Vegas2/images/2w.gif" alt="" /></td> </tr> <tr> <th width="60%"><div align="left" style="margin: 22px 0px 3px 0px;"><strong>Stories about </asp:Literal> <asp:Literal id="lblStoryHeader2" visible="false" runat="server" /> <asp:Literal id="lblStoryHeader3" visible="false" runat="server"></strong></div></th> <td width="40%"><div align="right" style="margin: 22px 1px 0px 0px;"><a class="LC" href="/Vegas2/Stories/stories.aspx?CelebID=</asp:Literal><asp:Literal id="lblStoryHeader4" visible="false" runat="server" /><asp:Literal id="lblStoryHeader5" visible="false" runat="server">&New=true">Have a story to tell? Add one here!</a></div></td> </tr> <tr> <td colspan="2"><img width="525" src="/Vegas2/images/2w.gif" alt="" /></td> </tr> <tr> <td height="4" colspan="2"></td> </tr> </asp:Literal>
-------------------------------------------------------------------------------------------------------------------------------- <asp:Repeater ID="CelebStories" runat="server"> <ItemTemplate> <tr> <td colspan="2"><img width="525" src="/Vegas2/images/2w.gif" alt="" /></td> </tr> <tr> <td height="13" colspan="2"></td> </tr> <tr> <td colspan="2"> <table width="100%" border="0" cellspacing="0" cellpadding="0"> <tr> <td width="90%"><strong><%# DataBinder.Eval(Container.DataItem, "StoryTitle") %></strong></td> <td width="10%" nowrap="nowrap" align="right"><div style="margin-right:20px;"><font color="#666666">Category: <%# DataBinder.Eval(Container.DataItem, "Category") %></font></div></td> </tr> <tr> <td colspan="2"><div style="margin: 10px 10px 10px 10px;"><%# DataBinder.Eval(Container.DataItem, "Story") %> <font size="2" face="Verdana" color="#666666">... [<a href="/Vegas2/Stories/stories.aspx?StoryID=<%# DataBinder.Eval(Container.DataItem, "StoryID") %>">Full Story</a>]</div></td> </tr> <tr> <td colspan="2"> <table border="0" cellpadding="0" cellspacing="0" width="100%"> <tr> <td width="30%" class="subinfo">Posted By: <a href="/Vegas2/Users/profile.aspx?uaid=<%# DataBinder.Eval(Container.DataItem, "UserID") %>"><%# DataBinder.Eval(Container.DataItem, ("UserName")) %></a></td> <td width="30%" class="subinfo">Date Posted: <%# String.Format("{0:d}", DataBinder.Eval(Container.DataItem, "DateCreated")) %></td> <td width="30%" class="subinfo">Story Views: <%# FormatNumber(DataBinder.Eval(Container.DataItem, "StoryViews"),0) %></td> <td width="10%" class="subinfo"><%# DataBinder.Eval(Container.DataItem, "PosNeg") %></td> </tr> </table> </td> </tr> </table> </td> </tr> </ItemTemplate> <SeparatorTemplate> <tr> <td height="13" colspan="2"></td> </tr> <tr> <td colspan="2"><img width="525" src="/Vegas2/images/2w.gif" alt="" /></td> </tr> <tr> <td height="2" colspan="2"></td> </tr> </SeparatorTemplate> <FooterTemplate> <tr> <td height="13" colspan="2"></td> </tr> <tr> <td colspan="2"><img width="525" src="/Vegas2/images/2w.gif" alt="" /></td> </tr> <tr> <td height="4" colspan="2"></td> </tr> <tr> <td colspan="2"><img width="525" src="/Vegas2/images/2w.gif" alt="" /></td> </tr> <tr> <td height="10" colspan="2"></td> </tr> </table> </FooterTemplate> </asp:Repeater><asp:Repeater ID="StoryHeader" runat="server"> <ItemTemplate> <table width="525" border="0" cellspacing="0" cellpadding="0"> <tr> <td colspan="2"><img width="525" src="/Vegas2/images/2w.gif" alt="" /></td> </tr> <tr> <th width="60%"><div align="left" style="margin: 22px 0px 3px 0px;"><strong>Stories about <%# DataBinder.Eval(Container.DataItem, "CelebName") %></strong></div></th> <td width="40%"><div align="right" style="margin: 22px 1px 0px 0px;"><a class="LC" href="/Vegas2/Stories/stories.aspx?CelebID=<%# DataBinder.Eval(Container.DataItem, "CelebID") %>&New=true">Have a story to tell? Add one here!</a></div></td> </tr> <tr> <td colspan="2"><img width="525" src="/Vegas2/images/2w.gif" alt="" /></td> </tr> <tr> <td height="4" colspan="2"></td> </tr> </ItemTemplate> </asp:Repeater>
Last edited by SheSaidImaPregy : Oct 4th, 2007 at 11:57 am.
![]() |
•
•
•
•
•
•
•
•
DaniWeb ASP.NET Marketplace
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
- Repeater,datalist, datagrid (ASP.NET)
- asp:repeater in a form? (ASP.NET)
- Using the Datalist Control as a Menu (ASP.NET)
- inverse functions (Visual Basic 4 / 5 / 6)
- dynamic tables (ASP.NET)
- Drop Downlist Not Loading (VB.NET)
- Repeater with Object as Value (C#)
- Some help understanding #define with C (C)
Other Threads in the ASP.NET Forum
- Previous Thread: NEWBIE - Insert data from ASP.Net application into mutiple SQL tables
- Next Thread: Accessing Label inside Repeater



Linear Mode