Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
DataGrid footer text updating
Message
 
 
Information générale
Forum:
ASP.NET
Catégorie:
Autre
Divers
Thread ID:
00848459
Message ID:
00848520
Vues:
14
>I have a totals item in the footertext of a DataGrid and the totals is always one refresh behind. I have pulled the code to do the refreshing out into a sub and I have tried calling that sub in the page load regardless of postback status, At the end of the databind process, and both. The problem remains...
>
>Any ideas?

The answer, I have discovered, is the OnItemDataBound attribute of the DataGrid tag. 1pt to 4GuysFromRolla for inadvertently steering me to the answer. :)
The following code works great.
'Be sure to add OnItemDataBound="UpdateCartSubTotal" to the datagrid tag on the HTML side
'eg- < DataGrid id="grdCart" runat="server" ShowFooter="True" OnItemDataBound="UpdateCartSubTotal">
        Dim CartSum As Double = 0.0
        Sub UpdateCartSubTotal(ByVal sender As Object, _
                                         ByVal e As DataGridItemEventArgs)
            'Item or AlternatingItem ?
            If e.Item.ItemType = ListItemType.Item Or _
                  e.Item.ItemType = ListItemType.AlternatingItem Then
                'Snip out the ViewCount
                Dim viewCount As Double = _
                     Convert.ToDouble(DataBinder.Eval(e.Item.DataItem, "Retail"))
                CartSum += viewCount
            ElseIf e.Item.ItemType = ListItemType.Footer Then
                e.Item.Cells(3).Text = _
                    "<P align='right'>Subtotal: </P>"
                e.Item.Cells(4).Text = _ 
                    "<P align='right'>" & Format(CartSum, "0.00") & "</P>"
            End If
        End Sub
~Joe Johnston USA

"If ye love wealth better than liberty, the tranquility of servitude better than the animated contest of freedom, go home from us in peace. We ask not your counsel or arms. Crouch down and lick the hands which feed you. May your chains set lightly upon you, and may posterity forget that ye were our countrymen."
~Samuel Adams

Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform