C# 页脚中的内容与ItemTemplate结果不同
在数据绑定方面,DataListC# 页脚中的内容与ItemTemplate结果不同,c#,asp.net,C#,Asp.net,在数据绑定方面,DataListFooterTemplate的查询结果是否与我们在ItemTemplate结果中使用的查询结果完全不同 例如: <ItemTemplate> <tr> <td>BookID: </td> <td><%#Eval("bookid")%</td> </tr> </ItemTemplate> <FooterTemplate> <tr> <t
FooterTemplate
的查询结果是否与我们在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>
图书编号:
使用ItemDataBound事件,而不是在设计时绑定它,如下所示
if( e.Item.ItemType == ListItemType.Footer )
{ Label myLabel = ((Label)e.Item.FindControl("mylabelid"));
mylabel.Text="datafrom db";
}
但ItemTempate的绑定可以保持原样,对吗?Adn我们在这里没有看到设计时的任何格式选项?让itemtemplate绑定保留在那里。可以在将项数据绑定中的内容分配给控件之前对其进行格式化。