码迷,mamicode.com
首页 > 其他好文 > 详细

gridview动态添加行(不用datatable实现)

时间:2016-08-20 10:10:46      阅读:95      评论:0      收藏:0      [点我收藏+]

标签:

GridViewRow newrow = new GridViewRow(0, 0, DataControlRowType.Separator, DataControlRowState.Normal); 
TableCell[] tc=new TableCell[5];
                    for (int i = 0; i < 5; i++)
                    {
                        tc[i] = new TableCell();
                    }
                    tc[0].Text = (GridView1.Rows.Count + 1).ToString();
                    tc[1].Text = "第一列内容";
                    tc[2].Text = "第二列内容";
                    tc[3].Text = "第三列内容";
                    tc[4].Text = "第四列内容";
                    tc[5].Text = "第五列内容";
                    newrow.Cells.AddRange(tc);
                    GridView1.Controls[0].Controls.AddAt(GridView1.Rows.Count + 1, newrow); 

 

gridview动态添加行(不用datatable实现)

标签:

原文地址:http://www.cnblogs.com/xiadaodao/p/5789654.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!