显示总计ListView中LayoutTemplate模板 [英] Displaying totals in the ListView LayoutTemplate
问题描述
我使用ListView控件(2008 ASP.NET)来显示一组数据线,并在底部我想有些合计。我最初将与当地一些功能,即&LT定义在LayoutTemplate模板页眉和页脚,并获得总额;%#GetTheSum()%>,但现在看来,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.
另外一个想法是把一个标签在LayoutTemplate模板和使用的FindControl来更新它。不知道这是可能的(会尽量不久)。
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).
什么是使用一个ListView显示总计的最佳方式?
What's the best way to show totals using a ListView?
UPDATE:解决方案<一href=\"http://stackoverflow.com/questions/212048/displaying-totals-in-the-listview-layouttemplate#212308\">here.
UPDATE: Solution here.
推荐答案
原来,的FindControl不工作:
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.
这篇关于显示总计ListView中LayoutTemplate模板的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!