2012-02-29 26 views
0

DataList FooterTemplate與我們在ItemTemplate結果中使用的數據綁定相比,是否有完全不同的查詢結果?頁腳中的不同內容與ItemTemplate的結果

對於如:

<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指定它。

任何建議,或者我應該使用一個完全不同的控制?

回答

0

而是結合其設計時,使用ItemDataBound事件如下

if(e.Item.ItemType == ListItemType.Footer) 
{ Label myLabel = ((Label)e.Item.FindControl("mylabelid")); 
    mylabel.Text="datafrom db"; 
} 
+0

但在ItemTempate的結合能保持原樣,對不對? Adn我們沒有在這裏查看任何格式化選項嗎? – Cipher 2012-02-29 10:10:54

+0

讓itemtemplate綁定保留在那裏。在將其分配給控件之前,可以格式化項目數據綁定中的內容。 – PraveenVenu 2012-02-29 10:15:15