Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / ASP.NET / DataGrid / August 2003

Tip: Looking for answers? Try searching our database.

Dataset Caching

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Larry Dodd - 27 Aug 2003 03:58 GMT
I have a datagrid that I have created a DataSet for and Bound the DataGrid
to it and the formatting of the data works fine when the page loads. I would
like to take the dataset that was created for the dataset and somehow keep
it in memory so that when I click on the Edit button in the EditColumn and
have to do Databind again I would like to use the dataset that is in memory
to rebind the datagrid to instead of having to reconnect to the database and
create the dataset again.

I already do this by putting the dataset in the ViewState but when I do a
DataBind in the Editcommand event the data is there but it loses all of its
formattig. I have stepped through the EditCommand procedure and it Databinds
ok but the Item_DataBound procedure is never called again. I assume that
this is the reason the data is not formatted correctly anymore. If I just
refresh the page it runs through the original procedure and the data is
formatted correctly like it was set in the DataGrid template. Any help would
be appreciated.
Ken Cox [Microsoft MVP] - 27 Aug 2003 04:14 GMT
Hi Larry,

The principle is pretty simple. You check if the cache contains the dataset. If
not you build it. Then you go ahead and use it.

This is pseudo code to show the idea.....

dim ds as dataset
ds=cache.("mydataset")
' Check if the dataset exists in the cache
if ds is nothing then
   ' do the stuff here to fill the dataset
   da.fill(ds)
      ' put the dataset into the cache
   cache.add("mydataset",ds,<otherstuff here like the cache length....>)
end if
datagrid1.datasource=ds

Does this help?

Ken
MVP [ASP.NET]

Signature

Microsoft MVPs have a question for *you*: Are you patched against the Worm?
http://www.microsoft.com/security/security_bulletins/ms03-026.asp

I have a datagrid that I have created a DataSet for and Bound the DataGrid
to it and the formatting of the data works fine when the page loads. I would
like to take the dataset that was created for the dataset and somehow keep
it in memory so that when I click on the Edit button in the EditColumn and
have to do Databind again I would like to use the dataset that is in memory
to rebind the datagrid to instead of having to reconnect to the database and
create the dataset again.

I already do this by putting the dataset in the ViewState but when I do a
DataBind in the Editcommand event the data is there but it loses all of its
formattig. I have stepped through the EditCommand procedure and it Databinds
ok but the Item_DataBound procedure is never called again. I assume that
this is the reason the data is not formatted correctly anymore. If I just
refresh the page it runs through the original procedure and the data is
formatted correctly like it was set in the DataGrid template. Any help would
be appreciated.

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.