I have a dataview, which is populated from data in a database.
I am storing this datagrid data in a dataview so I can sort it easily
(Dataview.sort() ), so I decided to turn off viewstate for the datagrid, to
send less traffic. So I cut the page from 111k down to about 50k in size,
but I need to call DataGrid.Source= and DataGrid.DataBind() on post back for
sorts, once on SortCommand (after sorting the dataview) and then again on
PageLoad (because data will not be available to sort when SortCommand is
called if it isn't bound, since I disabled viewstate).
Is there any problems with this? I figured storing the dataview in session
memory for sorting, I should just as well use it to repopulate the grid
rather than sending it all through viewstate. Providing this doesn't pose
memory problems on the server is this appoach acceptable?
very acceptable. I'm not sure how you are getting the sorting to work
without re-hooking the grid events in page_load. Is this a custom sort?
Anyway, the viewstate portion is a very effective performance optimization
technique.

Signature
Regards,
Alvin Bruney [ASP.NET MVP]
Got tidbits? Get it here...
http://tinyurl.com/3he3b
> I have a dataview, which is populated from data in a database.
>
[quoted text clipped - 10 lines]
> rather than sending it all through viewstate. Providing this doesn't pose
> memory problems on the server is this appoach acceptable?
Michael Johnson Sr. - 26 Jan 2004 17:07 GMT
I was doing the following in page_load:
private void Page_Load(object sender, System.EventArgs e)
{
if (!IsPostBack)
{
sqlDataAdapter1.Fill(dataSet11);
Session["dataView"] = dataSet11.Tables["Customers"].DefaultView;
ViewState["Sort"] = string.Empty;
ViewState["SortDirection"] = "ASC";
}
DataGrid1.DataSource = Session["dataView"];
DataGrid1.DataBind();
}
Then i reset the datasource and databind in the SortCommand. I disabled
ViewState on the DataGrid.
I understand this will cause alot of memory use for large applications if
the dataview gets large or alot of users. The fix for this would to
re-query the database instead of storing the dataview on the session stack,
I assume.
> very acceptable. I'm not sure how you are getting the sorting to work
> without re-hooking the grid events in page_load. Is this a custom sort?
[quoted text clipped - 18 lines]
> > rather than sending it all through viewstate. Providing this doesn't pose
> > memory problems on the server is this appoach acceptable?