如何为datagrid增加一个空行

如何为datagrid增加一个空行
[17 byte] By [huangl007-huangl] at [2008-2-12]
# 1
如果是于DATASET连接,直接添加到DATASET中
Erice-白雪公猪 at 2007-10-22 > top of Msdn China Tech,.NET技术,C#...
# 2
在DataTbale中增加一行即可
izzard-izzard at 2007-10-22 > top of Msdn China Tech,.NET技术,C#...
# 3
datarow.add....
zwxrain-Lilo at 2007-10-22 > top of Msdn China Tech,.NET技术,C#...
# 4
DataGrid绑定的是DataView.
增加
private void AddNewDataRowView(DataView dv)
{
DataRowView drv = dv.AddNew();
// Change values in the DataRow.
drv["ColumnName"] = "New value";
drv.EndEdit();
}
zhzuo-秋枫 at 2007-10-22 > top of Msdn China Tech,.NET技术,C#...
# 5
http://www.Codefund.cn/Develop/read_article.asp?id=27280
2066-子在川上曰 at 2007-10-22 > top of Msdn China Tech,.NET技术,C#...
# 6
DataView DvXsdy = DsXsdy.Tables[0].DefaultView;
DvXsdy.AllowNew = true;
dataGrid1.SetDataBinding(DvXsdy,"");
nedvedlh-shirley at 2007-10-22 > top of Msdn China Tech,.NET技术,C#...
# 7
SqlConnection myConnection = new SqlConnection(ConnectionString);
SqlDataAdapter myCommand = new SqlDataAdapter(SelectCommand, myConnection);

DataSet ds = new DataSet();
myCommand.Fill(ds);

// add a new blank row to the end of the data
object[] rowValues = { "", "", "" };
ds.Tables[0].Rows.Add(rowValues);

// figure out the EditItemIndex, last record on last page
int recordCount = ds.Tables[0].Rows.Count;
if (recordCount > 1)
recordCount--;
dgUserInfo.CurrentPageIndex = recordCount/dgUserInfo.PageSize;
dgUserInfo.EditItemIndex = recordCount%dgUserInfo.PageSize;

// databind
dgUserInfo.DataSource = ds;
dgUserInfo.DataBind();
lxcc at 2007-10-22 > top of Msdn China Tech,.NET技术,C#...