int i = 0;
int TotalPrice = 0;
float avgPrice = 0;
protected void gvProducts_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
i += 1;
TotalPrice+=
Convert.ToDouble(DataBinder.Eval(e.Row.DataItem,"UnitPrice"));
}
e.Row.Attributes.Add
("OnMouseOver", "style.backgroundColor='Lime'");
e.Row.Attributes.Add
("OnMouseOut", "style.backgroundColor='White'");
if(e.Row.RowType==DataControlRowType.Footer)
{
avgPrice = TotalPrice /i;
e.Row.Font.Bold = true;
e.Row.Cells[0].Text = "ราคาสินค้าเฉลี่ย : ";
e.Row.Cells[2].Text = avgPrice.ToString("#,##0.00");
e.Row.Cells[2].HorizontalAlign = HorizontalAlign.Right;
e.Row.BackColor = Color.YellowGreen;
}
}
convertค่าไม่ได้ครับ แต่ให้เป็น int16แล้วได้แต่ไม่ได้ค่าตามต้องการคับรบกวรอาจารย์พี่เป้หรือคนอื่นๆด้วยนะครับ ขอบคุณครับ
i wanna be da Developer man~!!!! how??