473,769 Members | 7,558 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Dropdown is not maintaining itz state after postback

Hi,
Currently iam facing a strange problem.. One dropdown in my page is not
keeping itz state after postback. Whichever the item i select irrespective of
that after the post-back the default selected item is the first one. This
happens even if i submitted the page by making the AutoPostback of the
dropdown true or by clicking on the submit button.
Even it’s not going to the DropDownList1_S electedIndexCha nged method.

A checking is already there at page load event to avoid filling the dropdown
at the time of postback.

The items are populating from database. The interesting matter is, this
problem comes only when i fill the dropdown from the database. if iam hard
coding the items then this problem is not there. That time itz maintaining
the state.

Anybody hav any idea what may be the problem

--
Deepson Thomas
May 30 '06 #1
5 2099
"Deepson Thomas" <De***********@ discussions.mic rosoft.com> wrote in message
news:C1******** *************** ***********@mic rosoft.com...
Anybody hav any idea what may be the problem


Move the code which populates the DropDown out of Page_Load and into
Page_Init
May 30 '06 #2
I hav a method which connects to DB and populates the dropdown. i changed the
calling of method from page load to page init as per ur suggestion but now
the data is not populating. If i move the calling back to page load then it
populates.
any idea what wrong with my code ?
--
Deepson Thomas
"Mark Rae" wrote:
"Deepson Thomas" <De***********@ discussions.mic rosoft.com> wrote in message
news:C1******** *************** ***********@mic rosoft.com...
Anybody hav any idea what may be the problem


Move the code which populates the DropDown out of Page_Load and into
Page_Init

May 30 '06 #3
"Deepson Thomas" <De***********@ discussions.mic rosoft.com> wrote in message
news:59******** *************** ***********@mic rosoft.com...
any idea what wrong with my code ?


Almost certainly because you haven't actually wired up Page_Init...

1) Open up the Web Form Designer generated code section

2) Open up the InitializeCompo nent method

3) Wire up the Page_Init method as well as the Page_Load method e.g.

this.Init += new System.EventHan dler(this.Page_ Init);
this.Load += new System.EventHan dler(this.Page_ Load);
May 30 '06 #4
Hi,
the this.Page_Load is wired up and OnInit method is there.
--
Deepson Thomas
"Mark Rae" wrote:
"Deepson Thomas" <De***********@ discussions.mic rosoft.com> wrote in message
news:59******** *************** ***********@mic rosoft.com...
any idea what wrong with my code ?


Almost certainly because you haven't actually wired up Page_Init...

1) Open up the Web Form Designer generated code section

2) Open up the InitializeCompo nent method

3) Wire up the Page_Init method as well as the Page_Load method e.g.

this.Init += new System.EventHan dler(this.Page_ Init);
this.Load += new System.EventHan dler(this.Page_ Load);

May 31 '06 #5
"Deepson Thomas" <De***********@ discussions.mic rosoft.com> wrote in message
news:FE******** *************** ***********@mic rosoft.com...
the this.Page_Load is wired up and OnInit method is there.


That's not what I actually said...
May 31 '06 #6

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

Similar topics

3
1999
by: phil2phil | last post by:
hi, had a question on preloading a dropdown. we have a textbox and dropdown on the page, user is suppose to enter in a zip into textbox, then the dropdown should load the state based on the zip. we can pull the state from the database on a zip match table, but how do we preload the dropdown, is there a way without posting back?
3
3063
by: Lloyd Sheen | last post by:
I have a page that works fine. I am trying to optimize the page by overriding some of the Information that is being saved in the hidden VIEWSTATE. If I make the properties of the dropdown False for ViewState and True for AutoPostBack, it does reload the page but does not call the SelectedIndexChanged event. If I put the ViewState to True then it is called. Does this mean that I cannot get that event and deal with it in better code
1
3656
by: Mad Scientist Jr | last post by:
I don't know how this is happening, but a dropdown control I have is resetting to the 2nd value on the list anytime a postback occurs. I have no initiation code outside of If Not (IsPostBack) I have EnableViewState set to true for the control - the control stays populated, it just is losing its selected value. The control is not contained in any panels or anything, just a Web
6
10697
by: Mark | last post by:
I have two dropdown lists. Both have autopostback set to true. In both dropdowns, when you select an item from the list, it redirects to the Value property of the dropdown. Nothing fancy. Let's say you select 1 of the items, and are properly redirected. You press the back button. I have three servers providing two different functionalities: 1. After pressing the back button, the item you selected in the dropdown is still selected.
1
1564
by: Ed Chiu | last post by:
Hi, I have 2 dropdown lists on an ASP.Net page, the first is a list of states of US, the second is City list. When user selects a state, the web page does a postback, create a DB connection and bind a dataset to city dropdown list. This is working for me. But I would like to do this on the client side for the following reasons: (1) Doing this on server side takes time, the postback and connecting to DB costs too much.
2
2457
by: Pete Moss | last post by:
During a postback event, I am having trouble retrieving the state of a CheckBox Control that I am dynamically adding to a DataGrid Control using ASP.NET 1.1. I have no trouble adding the TemplateColumn dynamically. I persist a DataSet in my Session object and I bind the CheckBox to the DataSet. So far so good. The CheckBoxes show up and the user interacts with them (checks a few, unchecks a few). The problem is that during a postback...
1
1447
by: Deepson Thomas | last post by:
Hi, Currently iam facing a strange problem.. One dropdown in my page is keeping itz state after postback. Whichever the item i selected is not the selected item after postback. it goes back to the first item again. This happens even if i submitted the page by making the AutoPostback of the dropdown true or by clicking on the submit button. Even itz not going to the DropDownList1_SelectedIndexChanged method. A checking is already there...
1
2152
by: clintonG | last post by:
I'm having a problem maintaining state with a Panel control in a MasterPage and I need help thinking through this process. The basic structure of the HTML in the Master looks like this... <asp:PanelActivatorLinkButton ... /> .... .... <asp:Panel Visible="" ...> <asp:LoadContentLinkButton ... /> <asp:ContentPlaceHolder ... />
0
1320
by: mark.norgate | last post by:
Hi I'm having a problem in adding controls to a page programmatically in response to a button click. Composite user controls added programmatically in the CreateChildControls() method work fine; they maintain their state as expected. Cool and groovy. However, since CreateChildControls() is called before the method that responds to the button click, say AddControl_Click(), for some reason, this control does not maintain its
0
9589
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9423
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
10214
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10048
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
9996
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,...
0
9865
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8872
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6674
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
5447
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

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.