473,471 Members | 1,967 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

EnableViewState problem

Hi, please can someone help with this? I have a dropdown list on an
aspx page bound to a table in an SQL Server database. EnableViewState
is set to true but when I change the entry in the drop down list the
setting doesn't stick and the first item in the list becomes selected.

Is there something else that needs to be done so that the selected item
remains selected?

thanks,

sean

Nov 17 '05 #1
8 1599
One reason could be that the dropdown list is cleared and bound everytime
the page is posted back. Use Page.IsPostback and fill the dropdown
accordingly.

Or, possibly some code logic is changing the selection before it is
accessed?

-Siva

"seans" <se******@yahoo.com> wrote in message
news:11**********************@g44g2000cwa.googlegr oups.com...
Hi, please can someone help with this? I have a dropdown list on an
aspx page bound to a table in an SQL Server database. EnableViewState
is set to true but when I change the entry in the drop down list the
setting doesn't stick and the first item in the list becomes selected.

Is there something else that needs to be done so that the selected item
remains selected?

thanks,

sean
Nov 17 '05 #2
One reason could be that the dropdown list is cleared and bound everytime
the page is posted back. Use Page.IsPostback and fill the dropdown
accordingly.

Or, possibly some code logic is changing the selection before it is
accessed?

-Siva

"seans" <se******@yahoo.com> wrote in message
news:11**********************@g44g2000cwa.googlegr oups.com...
Hi, please can someone help with this? I have a dropdown list on an
aspx page bound to a table in an SQL Server database. EnableViewState
is set to true but when I change the entry in the drop down list the
setting doesn't stick and the first item in the list becomes selected.

Is there something else that needs to be done so that the selected item
remains selected?

thanks,

sean
Nov 17 '05 #3
Hi Siva thanks for your reply. Do you mean to code the data binding
like this?

if (!Page.IsPostBack) {

sqlConnection2.Open();
sqlDataAdapter1.Fill(dataSet11);
DropDownList2.DataBind();

}

thanks.

sean

Nov 17 '05 #4
Hi Siva thanks for your reply. Do you mean to code the data binding
like this?

if (!Page.IsPostBack) {

sqlConnection2.Open();
sqlDataAdapter1.Fill(dataSet11);
DropDownList2.DataBind();

}

thanks.

sean

Nov 17 '05 #5
Yes. This way the dropdown selection is preserved on further post back.

"seans" <se******@yahoo.com> wrote in message
news:11*********************@g47g2000cwa.googlegro ups.com...
Hi Siva thanks for your reply. Do you mean to code the data binding
like this?

if (!Page.IsPostBack) {

sqlConnection2.Open();
sqlDataAdapter1.Fill(dataSet11);
DropDownList2.DataBind();

}

thanks.

sean
Nov 17 '05 #6
Yes. This way the dropdown selection is preserved on further post back.

"seans" <se******@yahoo.com> wrote in message
news:11*********************@g47g2000cwa.googlegro ups.com...
Hi Siva thanks for your reply. Do you mean to code the data binding
like this?

if (!Page.IsPostBack) {

sqlConnection2.Open();
sqlDataAdapter1.Fill(dataSet11);
DropDownList2.DataBind();

}

thanks.

sean
Nov 17 '05 #7
Hi Siva that fixes the problem. Thanks for your help.

sean

Nov 17 '05 #8
Hi Siva that fixes the problem. Thanks for your help.

sean

Nov 17 '05 #9

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

Similar topics

0
by: Dave Verwer | last post by:
Hi I have a problem which is easily reproducable using VS.NET 2003 and the .Net framework 1.1 (not tested with framework 1.0) regarding disabling ViewState for dynamically created controls. ...
1
by: Ravikanth[MVP] | last post by:
Hi Even though the Viewstate has been disabled, ASP.NET still uses about twenty bytes for Viewstate. Not only can you disable Viewstate at the page level, but you can also disable Viewstate...
4
by: Mike Drewery | last post by:
I want to post a form and not have the form maintain it's value. I am have tried setting EnableViewState = False at the control and on Page Load. When I submit the button my selection is returned. ...
6
by: AFN | last post by:
I have a server-side table, <asp:table id="tblData" EnableViewState="true" runat="server" /> and my code-behind adds rows of data to the table in code that says: if not page.ispostback then...
1
by: AC | last post by:
Hello, All Is it possible to set enableViewState='true' for single control on a page with enableViewState='false'. In particular I am interested in DropDownList, but neither using IDE to set...
3
by: Joe | last post by:
Hello all: From what I understand the ItemCommand, UpdateCommand, SortCommand, etc events for the datagrid require that the datagrid's enableVireState property is set to true. Does the...
7
by: Just D. | last post by:
Does anybody know any good solution to avoid this setting to be enabled? I guess Microsoft doesn't care of the Internet connection of the potential client working with asp.net. This EnableViewState...
2
by: Calvin KD | last post by:
Hi everyone, I have a datagrid to display search results. The search results at this stage we only return the first 500 records to speed up the search. The problem is, if I turn the...
2
by: teo | last post by:
I have a Listbox, if I set EnableViewStarte = False the AutopostaBack fired by SelectedIndexChanged doesn't work. The 'SelectedIndexChanged' event should call
1
by: =?Utf-8?B?VmlkZHM=?= | last post by:
Hi All, I am not able to get the sort event when i EnableViewState =false for data grid. Is there any relation betwn those two.Please comment. How can I get through this problem? Thanks in...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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
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
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
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
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,...
0
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...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.