DABUTTORE DI REP ASP
Domanda
I GUYS, non è presente Event Databunty su ASP Repeater Server Control?
Voglio solo vincolare tutti i miei dati, e alla fine crea un nuovo elemento oggetto e aggiungerlo, ma solo quando è vincolata tutti i dati
Soluzione
Lo uso per il calcolo delle ore totali nella raccolta.Anche se lo metto nel FooterTemplate
, dovresti essere in grado di ottenere il punto.
<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();
}
}
. Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow