ASP.NET with Datasets

N

nashak

Hello,

ASP.NET pages are disconnected html pages i.e once page is sent to the
browser, that is it.

Let's say that I have a datagrid on my page and I have used a dataset
to fill this grid only during the first visit to the page. My page
loads displaying the data in datagrid. What is the status of my
dataset? Is the dataset stored anywhere when the page got rendered (I
am not caching it)?

Now let's say that I use a button event to modify all the rows of the
datatable inside the dataset. Now since this is a postback, my dataset
is not created. So how does the dataadapter.update method work to
update the status of the rows of the table in a dataset?

I hope I've explained the problem clearly. If not, then please let me
know what information you need and I will try my best to provide it.

Thank you.
 
C

Cor Ligthert [MVP]

Nashak,

A asp webpage is stateless, that means that if you don't take special
actions everything that belongs to that page is removed after sending back
to the client.

You have four options to persist data
A shared class, a module or the cache, however those belong to *all* clients
using your application at that time.
The viewstate however than the dataset is tranported everytime over the line
The session.item

In my opinion the most simple to use for your problem (as I use it) is the
session.item
(Be aware that as it is about a dataset which is really never changing than
the first option can better be used)

Before or after that you bind the datagrid, you set the dataset in the
session.

At a postback, you set the session.item back in the dataset, which you (to
make it simple) have than declared global in your application.

I hope this helps,

Cor
 
N

nashak

Hello Cor,

Thank you for the response.

I've been using datasets etc for my code. I just had a question as how
is this dataset captured/stored if page is stateless.

You mention that I have to store the dataset explicitly. How is dataset
stored in the Viewstate?

Since the dataadapter's update method uses rowstatus to update rows, I
am assuming that the dataset is saved somewhere so that it can be
accessed on later visits to the page.
 
C

Cor Ligthert [MVP]

Nashak,

What you ask is something I ask myself as well often.

I have however never investigated it, it has to do with the binding, but
don't ask me how it goes exactly.

By the way, I forgot to tell that if you have set the saved dataset to the
datasource you have to bind it again.

Cor
 
G

Guest

True, the dataset is gone after the page is rendered.
When a postback occurs, the postbacked viewstate is used to re-create the
page's control hierarchy. In the case of a datagrid, all of the child
controls (labels, check boxes, buttons, etc) are recreated. In addition a
number of non-visible properties id the CONTROLS are recreated from the view
state (the datagrid's DataKeys collection, each row's RowState, etc).

So, the information you're getting is actually about, and persisted by) the
controls, not the original dataset, which no longer exists.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top