Display totals in a ListView LayoutTemplate

I am using a ListView control (ASP.NET 2008) to show a bunch of rows of data, and below I want to get some totals. First, I was going to define the header and footer in the LayoutTemplate and get totals with some local function, i.e. <% # GetTheSum ()%>, but it looks like the LayoutTemplate is not processing <% # ...%>.

Another thought would be to put a shortcut in the LayoutTemplate and use FindControl to update it. Not sure if this is possible (we will try in the near future).

What is the best way to show totals using ListView?

UPDATE: The solution is here .

+3
source share
3 answers

, FindControl :

CType(MyListView.FindControl("litTotal"), Literal).Text = GetTheSum()

, , .

+5

.

<asp:Literal ID="litTotal" runat="server" />

:

litTotal.Text = GetTheSum();
+1

You cannot reference a control in code because it is in a LayoutTemplate. Maybe with FindControl, but I have not tried it yet.

0
source

Source: https://habr.com/ru/post/1698399/


All Articles