User Name Password Register
DaniWeb IT Discussion Community
All
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
Reply
Join Date: Sep 2007
Posts: 1,058
Reputation: SheSaidImaPregy is an unknown quantity at this point 
Rep Power: 4
Solved Threads: 61
SheSaidImaPregy SheSaidImaPregy is offline Offline
Veteran Poster

Literal vs Repeater/Datalist for 2 values

  #1  
Oct 4th, 2007
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):
---------------------------------------------------------------- 
<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:&nbsp;&nbsp;<%# 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") %>&nbsp;<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:&nbsp;&nbsp;<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:&nbsp;&nbsp;<%# String.Format("{0:d}", DataBinder.Eval(Container.DataItem, "DateCreated")) %></td> <td width="30%" class="subinfo">Story Views:&nbsp;&nbsp;<%# 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>
or Below (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>
---------------------------------------------------------------- <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:&nbsp;&nbsp;<%# 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") %>&nbsp;<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:&nbsp;&nbsp;<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:&nbsp;&nbsp;<%# String.Format("{0:d}", DataBinder.Eval(Container.DataItem, "DateCreated")) %></td> <td width="30%" class="subinfo">Story Views:&nbsp;&nbsp;<%# 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>
Last edited by SheSaidImaPregy : Oct 4th, 2007 at 11:57 am.
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Sep 2007
Posts: 1,058
Reputation: SheSaidImaPregy is an unknown quantity at this point 
Rep Power: 4
Solved Threads: 61
SheSaidImaPregy SheSaidImaPregy is offline Offline
Veteran Poster

Re: Literal vs Repeater/Datalist for 2 values

  #2  
Oct 4th, 2007
Oops, old code. Anyway, I updated it into one literal. If anyone can let me know how to add database values that are databound to the repeater into the HeaderTemplate, that would be great. Less times I have to hit the database, the better!
Reply With Quote  
Join Date: Sep 2007
Posts: 1,058
Reputation: SheSaidImaPregy is an unknown quantity at this point 
Rep Power: 4
Solved Threads: 61
SheSaidImaPregy SheSaidImaPregy is offline Offline
Veteran Poster

Re: Literal vs Repeater/Datalist for 2 values

  #3  
Oct 4th, 2007
Solved it myself. Just used a literal but still would prefer a more stable method.
Last edited by SheSaidImaPregy : Oct 4th, 2007 at 5:40 pm.
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

DaniWeb ASP.NET Marketplace
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

Thread Tools Display Modes

Similar Threads
Other Threads in the ASP.NET Forum

All times are GMT -4. The time now is 4:06 am.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC