Click here to Skip to main content
15,892,927 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Sir, I am working with asp.net(Without database).Here I just include some fields and show the data in a grid view (without database).Here I add 2 drop down list and it shows all countries and state using this,
HTML
<script src="List_Country_State-master/countries.js" type="text/javascript"></script>


<asp:DropDownList ID="ddl_country" runat="server" >
<asp:ListItem Enabled="false" Text="Select Country" Value="-1">


<script language="javascript" type="text/javascript">
populateCountries("ddl_country", "ddl_state");</script>

Then,
I want to display the country,state selected into a grid view. this is done by this code,
drCurrentRow["Country"] = ddl_country.Text;
Bt it gives the index number, not the text of what country selected and also same for state.

How can I Solve it. please help me
Posted
Comments
F-ES Sitecore 1-Feb-16 6:57am    
You can't manipulate server-side dropdowns via client-side javascript. If you want to populate your dropdown via js then use a normal <select> element. When your page is submitted the asp:dropdwonlist is being recreated from the data that is in the ViewState and the changes you made via js are being ignored.
Member 12197595 1-Feb-16 23:32pm    
Thank you sir.. But my drop down list populate all country name as well as state name using this code..
Then I want to display which country is user selected ..This is not working in my code.. I cant access what is user selected.. Always it shows -1 . (When user select India, drCurrentRow["Country"] = ddl_country.Text; it show -1 not India.. and for all other country )

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900