Display Drop down list values group wise

kgovindarao523-21772
Posted by kgovindarao523-21772 under ASP.NET category on | Points: 40 | Views : 2364
Hi,

In Drop down list, I want to display cities in state, group wise.

Here is my Code:
<select id="Select1">
<option>------Andhra Pradesh-----></option>
<option>Hyderabad</option>
<option>Visakhaptanam</option>
<option>Tirupathi</option>
<option>Vijayawada</option>
<option>------Maharastra-----></option>
<option>Mumbai</option>
<option>Pune</option>
<option>Nagapur</option>
<option>Thane</option>
</select>


but, I want to display cities state wise and select only cities, not the states
In above drop down list i can select state also .

Solution to this problem is, specifying <optgroup> in select list.

Here is the code.
<select id="Select1">
<optgroup label="-------Andhra Pradesh-----" title="Andhra Pradesh">
<option>Hyderabad</option>
<option>Visakhaptanam</option>
<option>Tirupathi</option>
<option>Vijayawada</option>
</optgroup>
<optgroup label="------Maharastra-----" title="Maharastra">
<option>Mumbai</option>
<option>Pune</option>
<option>Nagapur</option>
<option>Thane</option>
</optgroup>
</select>


Thank you.

Comments or Responses

Posted by: vishalneeraj-24503 on: 12/27/2013 Level:Platinum | Status: [Member] [MVP] | Points: 10
Can this work for Asp.Net dropdownlist control?
Posted by: kgovindarao523-21772 on: 12/27/2013 Level:Bronze | Status: [Member] [MVP] | Points: 10

Login to post response