How to calculate average for each column in radgridview into a last row after filtering?

StackOverflow https://stackoverflow.com/questions/15253421

سؤال

I would like to know how to find average of column based on row filters?

private void monthlyGridView_Click(object sender, EventArgs e)
{
   List<double> everyQuestion = new List<double>();

    for (int i = 5; i < monthlyGridView.Columns.Count; i++)
    {
        eachQuestion.Clear();
       for (int j = 0; j < monthlyGridView.Rows.Count - 2; j++)
       {
          //mReport is DataTable which return values
          string value = mReport.Rows[j][i].ToString();
          eachQuestion.Add(double.Parse(value));
       }
          string columnAverage = String.Format("{0:0.00}", eachQuestion.Average());
          monthlyGridView.Rows[monthlyGridView.Rows.Count - 1].Cells[i].Value = columnAverage;


    }
}

this code only gives me average not filtered based average?

هل كانت مفيدة؟

المحلول

You can use the build in summary row for this functionality. More information is avaialble here

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top