簡體   English   中英

如何在C#中的datagridview中動態添加行

[英]How to add dynamically row in datagridview in C#

如何在C#中的datagridview中動態添加一行。 單元格總和並在最后一行打印總答案?

如果我正確的話,你想要一個頁腳行。 您必須添加一個

<FooterTemplate> </FooterTemplate>

在您的數據網格中。 然后,您可以在RowCreated,Page Unload事件(或您需要的地方)中使用它來修改內容並顯示所需的數據。

您可以將RowCreated事件用作:

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
        }
    }

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM