selectedIndexChanged后Gridview行信息消失
我在 UpdatePanels 中有一个带有 GridView 和 DetailsView 的主/详细信息设置。 编辑和更新 DetailsView 时,我希望这些更改反映在 GridView 中,但不重新绑定该数据(这可能会更改 selectedItem 的排序顺序以及它导致的其他问题)在 DetailsView ItemUpdated 上,我有以下内容:
' Update Gridview '
ProductsGridView.Rows(selectedIndex).Cells(1).Text = e.NewValues("ProductName")
ProductsGridView.Rows(selectedIndex).Cells(2).Text = e.NewValues("Category")
当正在更新,但是当在 Gridview 中选择新项目时,更新的文本就会消失。 这是为什么?我如何保留该信息? 当它反弹时,如果它改变位置就可以了,直到它重新绑定为止我希望该数据能够持续存在。 谢谢。
I have a master/details setup with a GridView and DetailsView both in UpdatePanels. When the DetailsView is edited and updated, I want these changes to be reflected in the GridView, but without rebinding that data (which could change the selectedItem's sort order among other problems it causes) On DetailsView ItemUpdated I have the following:
' Update Gridview '
ProductsGridView.Rows(selectedIndex).Cells(1).Text = e.NewValues("ProductName")
ProductsGridView.Rows(selectedIndex).Cells(2).Text = e.NewValues("Category")
This works fine when updating, but when a new item is selected in the Gridview, the updated text disappears. Why is this and how can I keep that info? When it is rebound it is fine if it changes position, put until it gets re-bound I would like that data to persist. Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
答案:这是因为单元格的文本没有存储在视图状态中。 我添加了文字控件来保存单元格的文本,并相应地更新了文字的文本,而不是使用单元格的文本,如下所示:
信息现在保存在视图状态中并且工作完美 =)
Answer: It was because the cell's text was not being stored in the viewstate. I added Literal controls to hold the cell's text and updated the literal's text accordingly instead of using the cell's text, like so:
The information is now kept in viewstate and works perfectly =)