繁体   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