473,500 Members | 1,661 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

AutoGenerateColumns and ViewState

Hi all,

Assuming datagrid's viewstate is enabled, then upon
postback
1. its data will be populated automatically if
AutoGenerateColumns is true
2. no data is populated if AutoGenerateColumns is false.

Why does case 2 happen? How can we fixe it? I do not want
to go to the database to get the same data again.

Thanks a lot.
Frank

Nov 18 '05 #1
1 1377
I think we're talking about three things here: 1) The grid structure itself,
2) The data shown in the grid, and 3) the data *behind* the grid.

The grid structure itself is recreated for you at each postback, whether you
AutoGenerate or add the columns yourself at design time (if you generate the
grid from scratch in code, then I believe you'd have to recreate the
structure *each* time the page loads).

The data that shows up in the grid will be retrieved from viewstate
(provided same grid has been recreated) on postback.

The data *behind* the grid (your original datasource) is gone forever,
unless you redo the query, or have saved the dataset in session, etc.
Remember that the viewstate of the grid only saves those columns that are in
the grid, and not the (possibly) larger set of columns in your original
datasource. For example, if somebody clicks on a row in your grid, you can
only get at the fields that you've shown (or hidden) somewhere on the grid.
Otherwise, you need to recreate the datasource (or the row at least).

One thing about the datagrid is that it's happy to take a null datasource,
in which case it will show no rows (and no columns if AutoGenerate is true).
What can happen is that you rebind the datagrid to the datasource, but if you
haven't rehydrated the datasource then you'll get nothing in the grid.

If there's nothing in here that helps, please repost with a little more
detail about what you're doing and when.

hth,

Bill

"Frank" wrote:
Hi all,

Assuming datagrid's viewstate is enabled, then upon
postback
1. its data will be populated automatically if
AutoGenerateColumns is true
2. no data is populated if AutoGenerateColumns is false.

Why does case 2 happen? How can we fixe it? I do not want
to go to the database to get the same data again.

Thanks a lot.
Frank


Nov 18 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
977
by: Frank | last post by:
Hi all, Assuming datagrid's viewstate is enabled, then upon postback 1. its data will be populated automatically if AutoGenerateColumns is true 2. no data is populated if AutoGenerateColumns...
9
21625
by: John Kirksey | last post by:
I have a page that uses an in-place editable DataGrid that supports sorting and paging. EnableViewState is turned ON. At the top of the page are several search fields that allow the user to filter...
3
2626
by: Steve Drake | last post by:
All, I have a CONTROL that contains 1 control (Control ONE), the 1 control that it can contain 1 or 2 control (Control A and B). Control A, raises and event and Control ONE receives this event...
10
2239
by: neo | last post by:
hi, I am studying ASP.NET and have few questions - 1) The session ID and values of controls is stored in VIEWSTATE variable. So now when we put EnableViewState="false" in Page directive and...
1
1754
by: Simon | last post by:
Hi everyone, I have a quick question that I hope someone can help me with: I've made a user control that contains a text box and some validation functionality. This control has a few extra...
7
2027
by: et | last post by:
I'm not sure I understand the use of the ViewState. Do I understand correctly that values of controls are automatically held in a hidden control called ViewState? If so, then why can't we get...
9
1848
by: Mark Broadbent | last post by:
Been a while since I've touched asp.net but one thing that always seems to fustrate me is the loss of state on variable declarations. Is there anyway (i.e. assigning an attribute etc) to instruct...
6
2058
by: hitendra15 | last post by:
Hi I have created web user control which has Repeater control and Linkbutton in ItemTemplate of repeater control, following is the code for this control On first load it runs fine but when...
12
1894
by: Nick C | last post by:
Hi How can i reduce the viewstate for my asp.net application. It is getting very large now. What is a good solution? thanks N
0
7018
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7183
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7235
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
6909
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7397
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5491
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
4923
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
1
675
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
317
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.