HighTechTalks DotNet Forums  

Use a label in a FooterTemplate control? Surely, there must be a way...

ASP.net ASP.net discussions (microsoft.public.dotnet.framework.aspnet)


Discuss Use a label in a FooterTemplate control? Surely, there must be a way... in the ASP.net forum.



Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old   
Groove
 
Posts: n/a

Default Use a label in a FooterTemplate control? Surely, there must be a way... - 05-31-2006 , 01:00 PM






I have a typical Repeater that contains a Template (html table). The
repeater / template lists many records and in the footer, I'd like to simply
SUM up the $$ amounts from all the records in the repeater. Easy enough.

So I tried to place a Label control in the footer and fill the Text of the
label from code. I get the label is not declared error. So how can I go
about doing this? I tried writing a helper function in the code-behind file
to get the value to place in the label but can't seem to get it work.

Any ideas? Thanks in advance!

(ASP.NET 2/VB)

<FooterTemplate>
<tr valign="top">
<td colspan="2" align="right" class="ColumnHeader">Total</td>
<td class="ColumnHeader" width="25%"><asp:Label ID="lblTotalCapitalBudgets"
runat="server" Font-Bold="true"
Text="<%#GetTotal(Container.DataItem("ParentRecord ID")%>" /></td>
</tr>
</table>
</FooterTemplate>



Protected Function GetTotal(intRecordID As Integer) As String

..typical function to run a SQL Statement to get a SUM..

End Function





Compiler Error Message: BC30451: Name 'lblTotalCapitalBudgets' is not
declared.




Reply With Quote
  #2  
Old   
Nathan Sokalski
 
Posts: n/a

Default Re: Use a label in a FooterTemplate control? Surely, there must be a way... - 06-01-2006 , 12:45 AM






Well, I haven't seen your entire code, but if you go to your code you should
see a section near the top inside the "Web Form Designer Generated Code"
region where all the Controls on the page are declared. Most (if not all) of
these will look like the following:


Protected WithEvents yourcontrolid As System.Web.UI.WebControls.HyperLink


If Visual Studio didn't add your Label to this list for you, you can add it
yourself, yours would look like the following:


Protected WithEvents lblTotalCapitalBudgets As
System.Web.UI.WebControls.Label


Something else I want to point out to you is that your quotes are mismatched
in the Text attribute. Try changing the Text attribute to look like the
following:


Text='<%#GetTotal(Container.DataItem("ParentRecord ID")%>'


Notice that the outer quotes are single quotes (') and the inner quotes are
double quotes ("). It is also a good idea and more efficient to get the sum
using SQL code rather than the ASP.NET code, if you need to know how to do
this let me know and I will be happy to help you. Good Luck!
--
Nathan Sokalski
njsokalski (AT) hotmail (DOT) com
http://www.nathansokalski.com/

"Groove" <noway (AT) noemail (DOT) com> wrote

Quote:
I have a typical Repeater that contains a Template (html table). The
repeater / template lists many records and in the footer, I'd like to
simply SUM up the $$ amounts from all the records in the repeater. Easy
enough.

So I tried to place a Label control in the footer and fill the Text of the
label from code. I get the label is not declared error. So how can I go
about doing this? I tried writing a helper function in the code-behind
file to get the value to place in the label but can't seem to get it work.

Any ideas? Thanks in advance!

(ASP.NET 2/VB)

FooterTemplate
tr valign="top"
td colspan="2" align="right" class="ColumnHeader">Total</td
td class="ColumnHeader" width="25%"><asp:Label
ID="lblTotalCapitalBudgets" runat="server" Font-Bold="true"
Text="<%#GetTotal(Container.DataItem("ParentRecord ID")%>" /></td
/tr
/table
/FooterTemplate



Protected Function GetTotal(intRecordID As Integer) As String

..typical function to run a SQL Statement to get a SUM..

End Function





Compiler Error Message: BC30451: Name 'lblTotalCapitalBudgets' is not
declared.






Reply With Quote
Reply




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.