ASP リピーター データバインド
質問
皆さん、ASP リピーター サーバーの現在のデータバインドされたイベントは制御されていませんか?
すべてのデータをバインドしたいだけで、最後に新しいItemTemplateを作成して追加しますが、すべてのデータがバインドされるのはいつですか
解決
これをコレクションの合計時間を計算するために使用します。に入れたのに、 FooterTemplate
, 要点は理解できるはずです。
<asp:Repeater ID="rptRecords" runat="server" OnItemDataBound="rptRecords_ItemDataBound">
protected void rptRecords_ItemDataBound(object sender, RepeaterItemEventArgs e)
{
if (e.Item.ItemType == ListItemType.Footer)
{
int totalHours = 0;
foreach (RepeaterItem item in ((Repeater)sender).Items)
{
Label lblRowHours = (Label)item.FindControl("lblHours");
if (lblRowHours != null)
totalHours += Convert.ToInt32(lblRowHours.Text);
}
((Label)e.Item.FindControl("lblHoursTotal")).Text = totalHours.ToString();
}
}
所属していません StackOverflow