在Gridview中,复制所选行下方的新行 [英] In Gridview,copy a new row below the selected row

查看:84
本文介绍了在Gridview中,复制所选行下方的新行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个网格视图,每行都有''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,

推荐答案

将MVC和JQuery用于这样的Web应用程序。

然后你可以做任何你想做的事情。

Asp.net Web表单模型适用于小而简单的应用程序。

请不要在这些服务器控制上浪费你的生命。
Use MVC and JQuery for such a web application.
Then you can do any thing you want.
Asp.net Web Form Model is for small and simple application.
Please dont waste your life on these server controles.


这篇关于在Gridview中,复制所选行下方的新行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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