DataGrid Won't come back

T

Tina

I have, dozens of times, displayed datagrids, datasourced by an .xsd
dataset, with textboxes in template columns and always been able to spin
through those grids on, say a button click event.

In a new project I am dynamicaly populating the datagrid columns, after
which I retrieve data and do the following...

da.fill(DataSet1) 'this is an untyped dataset
dg.datasource = DataSet1
dg.Databind()

At this point my datagrid displays exactly like I want it to.

BUT, on the button click event (which occurs after the user might changes
some fields) my datagrid is empty!!!!

This brings up a question: How was it that I am able to get the grid back in
my other dozen programs where the grid is datasourced by a .xsd dataset?
Why doesn't the grid contents (as changed by the user) exist in the click
event?
Thanks,
T
 
M

Mr Newbie

Each time the form is used it is destroyed. One had to either repopulate the
data on Page_Load or load it from a cached storage.

IE

If not Page.IsPostback then

'Load your dataset & bind it
'Save it to cache along with your dataadapter

Else

'Load dataset and adapter from cache it from cache.

End If
 
T

Tina

I'm not having a problem with the dataset or the dataadapter, they are fine
as I save the dataset.

It is the DATAGRID that is empty when the button click occurs. I can't
cache it because I want the changes from the user.
T
 
M

Mr Newbie

Have you remembered to DataBind the grid each time you reload the page ?
Make sure the Grid is rebound on Postback as well as the first render
 
T

Tina

I never rebind and I have never had a problem with it not being there. In
fact if I were to rebind (to it's datasource) I would lose the changes the
user put into the textboxes in the grid.

Anyway I found what was causing my problem... if the "Create Columns at run
time" checkbox is checked the grid contents does not persist to other
events - if it is not checked it persists just fine! How bout that.

T
 

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

Members online

No members online now.

Forum statistics

Threads
473,776
Messages
2,569,603
Members
45,189
Latest member
CryptoTaxSoftware

Latest Threads

Top