将最后一行手动添加到C#中的datagridview中

问题描述:

我想在从数据库中获取数据后向我的datagridview中添加行。 例如:将最后一行手动添加到C#中的datagridview中

Product - - - Price 
    1 - - - 100 
    2 - - - 100 
    3 - - - 100 
Total - - - 300 

总数是我手动添加的值。任何帮助提前感谢。

+0

这可能会帮助:http://*.com/questions/10063770/c-sharp-如何对附加一个新行到datagridview的,编程 – Rubixus

添加总和的标签在你FooterTemplate

,并在RowDataBound事件服务器端,

protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e) 
    { 

    if (e.Row.RowType == DataControlRowType.Footer) 
    { 
    //Do your code 
    } 
    }