问题描述
我有一个网格视图,每行都有''select''按钮,我将这个''select''按钮重命名为''copy row''。我的要求是,当我点击这个副本行按钮时,必须在所选行下方添加新行。我成功了。
为此,我在gridview_selectedIndexChanging事件中编写了代码:
I have a grid view, with ''select'' button in each row,i renamed this ''select'' button as ''copy row''.my requirement is, when i click on this copy row button, a new row has to add below the selected row. and i succeed in this.
for this, i wrote code in "gridview_selectedIndexChanging" event as:
int i = e.NewSelectedIndex;
GridViewRow gr = GridView1.Rows[i];
GridViewRow row = new GridViewRow(i, i, DataControlRowType.DataRow, DataControlRowState.Insert);
GridView1.Controls[0].Controls.AddAt(i + 2, row);
我在这种情况下成功了。
但是当我点击另一个''复制行''按钮时,第一个复制的行没有保留;我在这种情况下失败了。
希望我能得到最佳解决方案。
谢谢advance,
I succeed in this scenario.
But when i click on another ''copy row'' button, first copied row has not persisted;and i have failed in this case.
Hope i will get an optimum solution.
Thanks in advance,
推荐答案
这篇关于在Gridview中,复制所选行下方的新行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!