This problem is stopping me from winding up my project. I have a webform where there is a pop-up page that populates one text box and 2 dropdowns. And I also have a checkbox list that does a postback. Whenever the checkboxlist does a postback, one of the dropdownlist's value is reset. It happens with only one dropdown list. The text box and the other dropdownlist retain their value. I have put enableviewstate = true at both the page level and control level.
Somebody please help me.....what is the reason for this strange behavior.
Any response is highly appreciated...
SelectCommand="SELECT Num, StateName FROM State WHERE (Num < 63) OR (Num = 76) ORDER BY [StateName]">
</asp:SqlDataSource>
<asp:RequiredFieldValidator ID="RequiredFieldValidator_hsstate" ControlToValidate="hsstate" runat="server" ErrorMessage="Please select your highschool state"
I am using a drop-down pulling its data from a table...and the data is binding properly after every page load..it is the selected value that disappears..I mean the selectedindex,say 5, is reset after page load..whatever value the pop-up page selects is present till the page postsback...and after postback it is reset to "Please select the value".
in the above javascript, I have found that the selectedindex is always set to 0..ie; when i = 0, the if condition works and breaks and the selectedindex is always set 0, that is the reason my main page is not able to preserve the value and resets back after every postback.
I have no clue why the if condition is true only when i = 0....it is supposed to be true when the original dropdown's text is equal to the required text
I assume the way I am trying to select the dropdown using this script is wrong...
hello..i have temporarily solved my problem by replacing the dropdown with a text box..but I have one more problem...
in my pop-up window, the dataview has names that contain " 's " in their names like Byte's, etc....so when I am using my javascript to select this name, the javascript breaks at " 's ".
Ex: pick(Byte
where as it is expected to do pick(Bytes's, testcity)
How can I do this???
I never saw any code that would have a problem with the apostrophe (')...
Usually this will mess things up if you are defining strings using apostrophes instead of double quotes....consider using double quotes instead of single quotes (aka apostrophes) where ever this is a problem.