Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Displaying totals in the ListView LayoutTemplate

I'm using the ListView control (ASP.NET 2008) to show a bunch of lines of data, and at the bottom I want some totals. I was initially going to define the header and footer in the LayoutTemplate and get the totals with some local function, i.e. <%#GetTheSum()%>, but it appears that the LayoutTemplate does not process the <%#...%> syntax.

Another thought would be to put a Label in the LayoutTemplate and use FindControl to update it. Not sure if that's possible (will try shortly).

What's the best way to show totals using a ListView?

UPDATE: Solution here.

like image 328
gfrizzle Avatar asked Dec 12 '25 03:12

gfrizzle


1 Answers

It turns out that FindControl does work:

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

I'd still like to know if there might be a better way though.

like image 160
gfrizzle Avatar answered Dec 14 '25 19:12

gfrizzle



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!