在页面重新加载时保留gridview中的数据 [英] Retain data in a gridview on page reload

查看:81
本文介绍了在页面重新加载时保留gridview中的数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个gridview,它是从数据表中填充的。我使用Viewstate来保存数据。



现在,如果我从此页面重定向到新页面并再次返回此页面,我的所有数据都将丢失,并且gridview,datatable,viewstate显示为空。



如果页面重新加载,我怎样才能保留上一张桌子?



我是什么尝试过:



我尝试再次绑定viewstate,但显示为空

I have a gridview and its populated from a datatable. I have used Viewstate to hold the data.

Now if I redirect to a new page from this page and again come back to this page, all my datas are lost and the gridview, datatable, viewstate is showing empty.

How can I retain the previous table inspite of page reload?

What I have tried:

I have tried binding the viewstate again but its showing empty

推荐答案

Viewstate只有页面辅助功能,您无法在应用程序中保存数据

您可以在页面中播放它。不在应用程序内



要在应用程序内访问,您可以使用会话。



或者在



页面加载()方法



if(!ispostback)

{

//使用数据表重新绑定您的视图

}





如果你正在使用session,那么在绑定datatable之前检查你的

会话变量的值是否为null然后绑定如果条件允许,则使用数据表其他方式在会话变量中存储数据。
Viewstate can have only page accessibility you can not hold data within your app
You can play it within the page. not within the app

For access within app you can use session.

Or in

page load() method

if(!ispostback)
{
//rebind your gried view using datatable
}


And if you are using session then before binding with datatable check the value of your
session variable if it is null then bind with datatable else with stored data in your session variable in above if condition.


这篇关于在页面重新加载时保留gridview中的数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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