将行添加到网格视图 [英] Add row to grid view

查看:91
本文介绍了将行添加到网格视图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



如果是,如何?



是否可以以编程方式向C#ASP中的GridView添加一行?

我想直接从代码中添加静态数据,而不是从数组或数据源中添加静态数据

code> DataTable dt = new DataTable();
DataRow dr = dt.NewRow();
dr [Column1] = string.Empty;
dt.Rows.Add(dr);

然后,您可以将 GridView 绑定到 DataTable ...

  gv.DataSource = dt; 
gv.DataBind();


Is it possible to programmatically add a row to a GridView in C# ASP?

If yes, how ?

I want to add static data directly from the code, not from an array nor an datasource

解决方案

DataTable dt = new DataTable();
DataRow dr = dt.NewRow();
dr["Column1"] = string.Empty;
dt.Rows.Add(dr);

You can then bind your GridView to the DataTable...

gv.DataSource = dt;
gv.DataBind();

这篇关于将行添加到网格视图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆