How to display statistics in the DataGrid footer

xiaoxiao2021-03-06  19

Write the following code in the DataGrid ItemDataBind event:

INT SUM = 0;

IF (E.Item.ItemIndex> 0)

{

Sum = int.parse (E.Item.cells (3) .text);

}

Else

IF (E.Item.ItemType == ListItemType.footer)

{

E.Item.cells [0] .Text = "Total:";

E.Item.cells [1] .Text = Sum.toString ();

E.Item.cells [2] .Text = "average:";

E.Item.cells [3] .Text = ((int)). Tostring ();

}

// Due to the simple page code, it is not written.

转载请注明原文地址:https://www.9cbs.com/read-44374.html

New Post(0)