当前位置: 代码迷 >> ASP.NET >> gridview在客户端平添一行
  详细解决方案

gridview在客户端平添一行

热度:8161   发布时间:2013-02-25 00:00:00.0
gridview在客户端添加一行
asp:GridView使用DataSourceID="SqlDataSource1"
如何在public void custom_rowcomand(Object sender, GridViewCommandEventArgs e)事件中在客户端增加一行,而不是通过重新绑定数据库
例如:
列1 列2 列3
a b 增加一条记录
c d 增加一条记录
通过点击增加一条记录,实现
列1 列2 列3
a b 增加一条记录
a b 增加一条记录
c d 增加一条记录

------解决方案--------------------------------------------------------
没试,但觉得应该override Reander()方法。

Table gridTable = (Table)GridView1.Controls[0];


GridViewRow row = new GridViewRow(rowIndex, rowIndex, DataControlRowType.DataRow, DataControlRowState.Normal);
TableCell cell = new Cell();
//Cell里增加几列TextBox
row.Cells.Add(cell);
gridTable.Contrls.Add(rowIndex, row);

....


这个rowIndex是否需要存在ViewState里,还是楼主自己试试吧。
  相关解决方案