页脚中的内容与ItemTemplate结果不同
本文关键字:ItemTemplate 结果 | 更新日期: 2023-09-27 18:26:03
与我们在ItemTemplate结果中使用的数据绑定相比,DataList FooterTemplate
是否具有完全不同的查询结果?
例如:
<ItemTemplate>
<tr>
<td>BookID: </td>
<td><%#Eval("bookid")%</td>
</tr>
</ItemTemplate>
<FooterTemplate>
<tr>
<td>Last purchase: </td>
<td><%#Eval("")% //don't have a the result in the ItemTemplate queried DataSource result. Need to do a separate query for this and enter the columnID here</td>
</tr>
</FooterTemplate>
我需要运行不同的查询才能在页脚中获得结果。为此,DataList的DataSource中也应该有相同的结果,这样我就可以使用ID来指定它。
对此有什么建议吗?或者我应该使用完全不同的控件吗?
不要在设计时绑定它,而是使用下面的中的ItemDataBound事件
if( e.Item.ItemType == ListItemType.Footer )
{ Label myLabel = ((Label)e.Item.FindControl("mylabelid"));
mylabel.Text="datafrom db";
}