0

How can I dynamically add a row in datagridview in c#. Sum of cell and print total answer in the last row?

Martin Evans
  • 45,791
  • 17
  • 81
  • 97

1 Answers1

0

You want a footer row if I am correct. You must add a

<FooterTemplate> </FooterTemplate>

in your data grid. Then you can use it in RowCreated, Page Unload events (or where you need) to modify contents and display desired data.

You could use RowCreated event as :

protected void MyGrid_RowCreated(object sender, GridViewRowEventArgs e)
    {
        if (e.Row.RowType == DataControlRowType.Footer)
        {
            //e.Row.FindControl("what ever control i have");
            //use the control to modify content
        }
    }
TSungur
  • 396
  • 2
  • 9