PDA

View Full Version : سوال: برای ذخیره dataset از چی استفاده کنم ؟



Modifier
دوشنبه 03 خرداد 1389, 10:37 صبح
سلام

برای استفاده ار دیتاست در صفحه پس از رفرش شدن از session استفاده کنم یا viewstate؟

با تشکر.

Vahid_moghaddam
دوشنبه 03 خرداد 1389, 11:59 صبح
viewstate مناسب این کار نیست. به این مقاله نگاه کنید:
http://msdn.microsoft.com/en-us/library/ms972427.aspx

Session State or ViewState?

There are certain cases where holding a state value in ViewState is not the best option. The most commonly used alternative is Session state, which is generally better suited for:


Large amounts of data. Since ViewState increases the size of both the page sent to the browser (the HTML payload) and the size of form posted back, it's a poor choice for storing large amounts of data.
Secure data that is not already displayed in the UI. While the ViewState data is encoded and may optionally be encrypted, your data is most secure if it is never sent to the client. So, Session state is a more secure option. (Storing the data in the database is even more secure due to the additional database credentials. You can add SSL for even better link security.) But if you've displayed the private data in the UI, presumably you're already comfortable with the security of the link itself. In this case, it is no less secure to put the same value into ViewState as well.
Objects not readily serialized into ViewState, for example, DataSet. The ViewState serializer is optimized for a small set of common object types, listed below. Other types that are serializable may be persisted in ViewState, but are slower and generate a very large ViewState footprint.

Modifier
چهارشنبه 26 خرداد 1389, 09:31 صبح
کدام بهتره :

1 - یکبار واکشی اطلاعات(هرگاه تغییراتی اعمال شد) و ریختن آن توی Session


Session["DataSet"] = fetch_data();


2 - در هر بار که میخواهیم استفاده کنیم واکشی انجام دهیم و در متغیر DataSet ذخیره کنیم.


DataSet ds = fetch_data();


؟؟؟