Ok Here's the issue..
I have small page which has label, dropdownlist and a submit button.
<div>
<asp:label id="Message" runat="server"/>
<br />
Which city do you wish to look at on hotels for?<br /><br />
<asp:dropdownlist id="Dropdownlist1" runat="server" EnableViewState="true">
</asp:dropdownlist>
<br /><br /><br /><br />
<input type="Submit" />
</div>
On form load i am inserting items into the dropdownlist and on the button click i am displaying the count of the items in the dropdownlist. Here's the code for that.
if (Page.IsPostBack)
{
Message.Text = "You have selected " + Dropdownlist1.Items.Count.ToString();
}
else
{
Message.Text = "You have selected " + Dropdownlist1.Items.Count.ToString();
Dropdownlist1.Items.Add("Madrid");
Dropdownlist1.Items.Add("Chennai");
Dropdownlist1.Items.Add("New York");
}
Here's the funny part. If i run it directly from the IDE, its working perfectly fine. I get the count as 0 the first time and 3 when i press submit button. I need to run this small code on an existing virtual directory. If i run the same aspx page within that virtual directory, i get count 0 for the for the first time it loads. When i click submit, i get count as 0 and i don't see any items in the dropdownlist, it is getting cleared. I have set viewstate to true so that i remember what was inserted. I am not sure what difference is there when i run it from IDE and when i run it from another virtual directory. I am fairly new to Asp.Net so i have exhuasted all my options here so to find out how a dropdownlist works. Is there a config i am missing here ?. Btw just FYI, I am facing the same issue when i put the DropDownList in a Wizard Control. When run from IDE it is working fine but when i run from the virtual directory its not getting the selected value neither is it remembering the items in the dropdownlist.
Any help on this would be appreciated.