473,721 Members | 2,235 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

GridView Footer controls not retaining viewstate

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
2 3504
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
EmptyDataTempla te 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
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*******@sier raonline.comwro te in message
news:eT******** ********@TK2MSF TNGP05.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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
1944
by: John Crowley | last post by:
I keep running into this over and over again... I want a block server control that renders a header and footer, and child controls in between. But I don't want a templated control, for the following reasons: 1) Render blocks are not allowed inside a templated control. 2) I want the inner controls scoped at the parent aspx (or ascx), not at the template naming container. This type of control would be ideal for website headers and...
1
9354
by: Miguel Dias Moura | last post by:
Hello, I have a GridView in my page which is created in runtime. It works fine. My page has 2 Asp Buttons: - The HIDE button makes GridView.Visible = False; - The SHOW button makes GridView.Visible = True. I press HIDE and the GridView disappears as expected. After it I press SHOW and the GridView doesn't show.
2
2757
by: Flinky Wisty Pomm | last post by:
Hi all, I've got a really annoying problem that I need to fix sharpish. I've got a GridView derived control which has a templated header and footer. It works wonderfully on the first render but then the header/footer vanish into thin air. If I add the header/footer onDataBound then they disappear when I do a postback with no databinding. If I add them during PreRender, then they persist, but one of my data rows is emptied for each time I...
9
3528
by: hazz | last post by:
I want to display 'n' records for a table-driven data entry page. The first column should be readonly and the 2nd column, a checkbox WRITABLE (NOT READONLY). I can't use the gridview because it creates -> checked="checked" disabled="disabled" What I need is more like this; <form id="form1" runat="server"> <div> <table>
13
42053
by: AG | last post by:
I have a gridview that I bind to a List(of Type) at runtime. Not using a datasource control. The gridview has a template column with an imagebutton whose commandname is set to 'Delete'. The footer template has an commandbutton with the commandname set to 'Insert'. Both buttons cause postback, however the RowCommand event does not fire. How can I get the rowcommand to fire?
0
1302
by: J Li | last post by:
I have a GridView with paging enabled with controls set up in the footer for adding new rows. In one column, I have two related dropdown list controls, DrowDown B's list should change depending on the selected value in DropDown A. However, to maintain the viewstate of these control seems impossible. If I populate DropDown A when (If !IsPostBack), then DropDown A would be empty when I go to a different page of the GridView. But if I...
8
7732
by: gerry | last post by:
The PagerSettings.Visible property is not being handled properly by the GridView control. The value assigned to this property is not applied until after a postback. Simplest test : .aspx containing a single gridview - enable paging and give enough data to page. add checkbox with auto postback enable add button with auto postback enable in the GridView1_PreRender method add the following : GridView1.HeaderRow.Enabled =
3
7332
by: pvong | last post by:
VB.NET How do you change a gridview from Update mode to normal mode? I'm usually dealing for Formviews and there is a ChangeMode option but I don't see one for Gridviews.
1
1150
by: seanwalsh | last post by:
Hi I have a footer row in a gridview that allows inserting of records into a table. One of the controls is a DropDownList control. I want this control to default to the value in the QueryString. So I have this code: protected void Page_Load(object sender, EventArgs e) { DropDownList MenuInsert = gridviewPages.FooterRow.FindControl("MenuInsert") as DropDownList; MenuInsert.SelectedValue =...
0
8730
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9215
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9131
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
6669
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5981
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4484
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4753
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3189
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2130
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.