if (e.Row.RowIndex >,网站优化培训;= 0)
{
sum1 += Convert.ToDouble(e.Row.Cells[6].Text);
sum2 += Convert.ToDouble(e.Row.Cells[7].Text);
}
else if (e.Row.RowType == DataControlRowType.Footer) {
e.Row.Cells[1].Text = "总数:";
e.Row.Cells[2].Text = sum1.ToString();
e.Row.Cells[3].Text =sum2.ToString();
e.Row.Cells[4].Text =sum1/sum2;
现在想求比例,sum1/sum2的比例该怎么转换,结果需要保留两位小数
{
sum1 += Convert.ToDouble(e.Row.Cells[6].Text);
sum2 += Convert.ToDouble(e.Row.Cells[7].Text);
}
else if (e.Row.RowType == DataControlRowType.Footer) {
e.Row.Cells[1].Text = "总数:";
e.Row.Cells[2].Text = sum1.ToString();
e.Row.Cells[3].Text =sum2.ToString();
e.Row.Cells[4].Text =sum1/sum2;
现在想求比例,sum1/sum2的比例该怎么转换,结果需要保留两位小数
使用Math.Round函数。
double sum1 = 125.89;double sum2 = 23.45;double result = sum1/sum2;e.Row.Cells[4].Text =Math.Round(result, 2, MidpointRounding.AwayFromZero).ToString();