tags:

views:

351

answers:

2

I would Like to Know How I could Fill A DropDownList from 2 Tables. I have Tables: Categories Subcategories

I should look like this: -- Vehichles -- //From Categories Cars //From SubCategories Bikes -- Houses -- Vila Aparatment

This tables are conected to eachother with foregin keys. and I use Linq to SQL.

Any Good Solution how to fill a dropdownlist from 2 tables?

+2  A: 

For display purposes, I'd recommend using the seldom used optiongroup tag.

For example:

<select>
  <optgroup label="Swedish Cars">
    <option value="volvo">Volvo</option>
    <option value="saab">Saab</option>
  </optgroup>
  <optgroup label="German Cars">
    <option value="mercedes">Mercedes</option>
    <option value="audi">Audi</option>
  </optgroup>
</select>

This will group your sub categories together for easier display in the dropdown.

nikmd23
A: 
Frajer