By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,458 Members | 1,278 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,458 IT Pros & Developers. It's quick & easy.

GridView Footer controls not retaining viewstate

P: n/a
I'm using a GridView inside a Wizard Control with a textbox and two
listboxes in the footer. I populate these listboxes from the database if the
page isn't on postback (and the textbox is left blank initially). All of
these controls have viewstate enabled.

When the user fills out the textfield and clicks ADD, I do a check for
validation of the data. If the user does not select a valid listbox entry, I
abort the rest of the add, and make visible a label that tells them what
they need to select (Yes, I know of validators, but had horrendous issues
with them in conjunction with the gridview and wizard).

The problem is that when this situation occurs, the textbox is cleared, and
the two listboxes are empty (no viewstate). I was under the impression that
if I had viewstate enabled, this information would be retained.

Am I missing something? Any insight appreciated.

Tim

Dec 12 '07 #1
Share this Question
Share on Google+
2 Replies


P: n/a
Hello Tim.

I had been struggling with a similar problem and GOD knows how many hours I
just wasted on it.

Basically, I have come to realize that Gridview footers are not very good at
handling controls like listboxes and dropdownlists.
There are 2 ways you can go ahead.

1) Put your sqldatasource (the one to which you have bound your listbox to),
within its Update Panel, rather than outside it.
For some reason, I have seen that even if there is an async postback, the
listbox / dropdown list experience problems if the sqldatasource they are
bound to is outside the update panel.

2) If 1) does not work, then you have got no option but to remove both
EmptyDataTemplate and Footer template from grid views and put your listbox
and textbox outside the grid and then follow the rest of your logic as usual.
But make sure that you still put your sqldatasource within the containing
update panel.

Hope this helps.

"Tim Royal" wrote:
I'm using a GridView inside a Wizard Control with a textbox and two
listboxes in the footer. I populate these listboxes from the database if the
page isn't on postback (and the textbox is left blank initially). All of
these controls have viewstate enabled.

When the user fills out the textfield and clicks ADD, I do a check for
validation of the data. If the user does not select a valid listbox entry, I
abort the rest of the add, and make visible a label that tells them what
they need to select (Yes, I know of validators, but had horrendous issues
with them in conjunction with the gridview and wizard).

The problem is that when this situation occurs, the textbox is cleared, and
the two listboxes are empty (no viewstate). I was under the impression that
if I had viewstate enabled, this information would be retained.

Am I missing something? Any insight appreciated.

Tim

Dec 18 '07 #2

P: n/a
Still rather curious if anyone has run into this. We went live anyway, since
it didn't stop the ability of users to complete the wizard. Still, I'd love
to know why when viewstate is enabled, these dynamically added controls do
not retain their settings after postback.

Tim

"Tim Royal" <ti*******@sierraonline.comwrote in message
news:eT****************@TK2MSFTNGP05.phx.gbl...
I'm using a GridView inside a Wizard Control with a textbox and two
listboxes in the footer. I populate these listboxes from the database if
the page isn't on postback (and the textbox is left blank initially). All
of these controls have viewstate enabled.

When the user fills out the textfield and clicks ADD, I do a check for
validation of the data. If the user does not select a valid listbox entry,
I abort the rest of the add, and make visible a label that tells them what
they need to select (Yes, I know of validators, but had horrendous issues
with them in conjunction with the gridview and wizard).

The problem is that when this situation occurs, the textbox is cleared,
and the two listboxes are empty (no viewstate). I was under the impression
that if I had viewstate enabled, this information would be retained.

Am I missing something? Any insight appreciated.

Tim

Jan 2 '08 #3

This discussion thread is closed

Replies have been disabled for this discussion.