Adding footer value to datagridview in c #

I have 2 datatables. One of them has the actual value of this table as selected by the user, and the next has the aggregated value for this table. I. Any total or average. I want to show this as a footer in C # datagridview. How can I do it??? In asp.net we have a RowDataBound event similar to what it looks like in C #, but which I can't find.

+2


a source to share


1 answer


You can use an ondatabound

event GridView

to populate the footer. Example:



protected void GridView1_DataBound(object sender, EventArgs e)
{
    GridView grid = sender as GridView;

    grid.FooterRow.Cells[0].Text = CustomDataSource.GetAggregated.Rows[0]["Name"].ToString();
    grid.FooterRow.Cells[1].Text = CustomDataSource.GetAggregated.Rows[0]["Total"].ToString();
}

      

0


a source







All Articles