在运行时向网格添加新行时数据消失 [英] Data disappears on adding a new row to the grid at run time

查看:104
本文介绍了在运行时向网格添加新行时数据消失的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个网格视图.我还有一个向GridView添加行"按钮.现在假设,我已经选择了第一行下拉列表中存在的数据,并且当我单击``将行添加到GridView''时,另一行被添加到了网格中,但是在第一行中选择的数据消失了. br/>
请帮忙.

I have a grid view. I also have a ''Add Row to GridView'' button. Now suppose, I have selected data present in the drop down list in the first row and when I click on the ''Add Row to GridView'', another row gets added to the grid but the data selected in the first row disappears.

Please help.

推荐答案

您必须编写SetPreviousData方法来解决此问题,因为在单击按钮时会发生自动回发,因此您之前选择的数据将消失.
You have to write SetPreviousData method to solve this issue, because on button click autopost back will happen so , the data which you selected before will go off.


我在这里使用了两个网格视图,例如A和B.
我显示的是用户网格视图A,而不是网格视图B.
我要做的是每当添加新行时,都将网格视图A的内容放到网格视图B中,当添加该行时,网格视图B的内容显示在A中.

这可能不是最好的处理方法,但它可以工作.另外,我们正在使用EDMX从数据库中获取数据
I have used two grid views here, say A and B.
I am showing the user grid view A and not grid view B.
What I am doing is whenever I add a new row, I am putting the contents of grid view A to grid view B and when the row gets added, the contents of grid view B are shown in A.

This might not be the best method of doing things but it works. Also, we are using EDMX to get data from database


这篇关于在运行时向网格添加新行时数据消失的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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