2013-08-05 53 views
0

我想在從數據庫中獲取數據後向我的datagridview中添加行。 例如:將最後一行手動添加到C#中的datagridview中

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

總數是我手動添加的值。任何幫助提前感謝。

+0

這可能會幫助:http://stackoverflow.com/questions/10063770/c-sharp-如何對附加一個新行到datagridview的,編程 – Rubixus

回答

2

添加總和的標籤在你FooterTemplate

,並在RowDataBound事件服務器端,

protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e) 
    { 

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