将空白行添加到GridView(ASP.NET 3.5) [英] Adding a blank row to a GridView (ASP.NET 3.5)

查看:222
本文介绍了将空白行添加到GridView(ASP.NET 3.5)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



任何人都可以共享用于将空白行添加到GridView的代码吗?我想在网格顶部添加一个空白行,即在索引[0]上.

在此先感谢.

Hi,

Can any one share code for adding a blank row to a GridView? I want to add a blank row to the top of the grid, i.e., on index[0].

Thanks in advance.

推荐答案

我要说的最简单的方法是在将空记录绑定到网格之前向数据源添加一个空记录.

您也许可以处理数据绑定事件并添加一行.
I would say the easiest way is to add an empty record to the datasource before it is bound to the grid.

You may be able to handle the databound event and add a row.


GridView数据绑定了吗?如果是这样,请在基础表中插入一行.

Is the GridView databound? If so, insert a row to the underlying table.

DataTable dt ...

DataRow newRow = dt.NewRow();
// set row fields
dt[0] = "whatever";

dt.Rows.InsertAt(0, newRow);

myDataGrid.DataSource = dt;


这篇关于将空白行添加到GridView(ASP.NET 3.5)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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