Re: Use a label in a FooterTemplate control? Surely, there must be a way...
- From: "Nathan Sokalski" <njsokalski@xxxxxxxxxxx>
- Date: Thu, 1 Jun 2006 00:45:20 -0400
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("ParentRecordID")%>'
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@xxxxxxxxxxx
http://www.nathansokalski.com/
"Groove" <noway@xxxxxxxxxxx> wrote in message
news:udU8%23ONhGHA.1864@xxxxxxxxxxxxxxxxxxxxxxx
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("ParentRecordID")%>" /></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.
.
- Prev by Date: Re: cannot convert from 'string' to 'system.datetime'
- Next by Date: How to Implement a Browse Button in asp.net WebApplication
- Previous by thread: Re: cannot convert from 'string' to 'system.datetime'
- Next by thread: How to Implement a Browse Button in asp.net WebApplication
- Index(es):
Relevant Pages
|