DataGrid是用来数据绑定的,最好的绑定源自然是DataSet.所以如果你要实现对DataGrid添加数据,先要对DataSet添加数据。
示例:
DataRow row=ds.Tables["Agent"].NewRow(); //ds为你初始化后的DataSet
row["AgentName"]="Agent1";
row["Description"]="It's an agent";
ds.Tables["Agent"].Rows.Add(row);
ds.AcceptChanges();
dgrd1.DataSource=ds.Tables["Agent"].DefaultView;
dgrd1.DataBind();
示例:
DataRow row=ds.Tables["Agent"].NewRow(); //ds为你初始化后的DataSet
row["AgentName"]="Agent1";
row["Description"]="It's an agent";
ds.Tables["Agent"].Rows.Add(row);
ds.AcceptChanges();
dgrd1.DataSource=ds.Tables["Agent"].DefaultView;
dgrd1.DataBind();
解决方案 »
- asp.net TreeView选择节点添加到GridView
- 求:自定义分类思路 asp.net
- 如何把aspx cs 放在dll中执行?
- System.Runtime.InteropServices.COMException: 系统未找到指定的资源
- 如何限制同一帐号不能同时多次登录或同时在线?
- mobile asp.net问题,征求爱好者
- VS2005可以打开VS2003的项目吗?
- 急,急,急 如何实现点击Button按钮先执行服务器端的事件,再执行客户端的事件.
- 我想在删除记录时出现提示窗口,该怎样实现?
- @@@@@@@@@高手点破@@@@@@@@@@
- 如何使用ASP.NET按需生成图片文件?高手帮帮忙~~在线等..
- 在一台机器上的项目,在另一台机器上打开,不能运行!
http://www.dotnetbips.com/displayarticle.aspx?id=125
希望大家继续发表解决的方法!