Heres the problem, that has taken me ages to spot. I have a databound dropdown box filled via a stored procedure. enabledviewstate is true as is autoPostback. When I select certain items in the dropdown, sometimes another item is selected instead. Here is the HTML of the dropdown
If for example I pick A STURROCK, the dropdown automatically changes to A COWAN. I have noticed this is because these two items have the same value - "ES".Code:<select name="ddEntitys" onchange="javascript:setTimeout('__doPostBack(\'ddEntitys\',\'\')', 0)" id="ddEntitys"> <option value="%">All</option> <option value="MR">A HAQUE </option> <option value="CM">A & A SECURITY TECHNOLOGIES LTD </option> <option value="LN">A & A SECURITY TECHNOLOGIES LTD </option> <option value="WM">A & A SECURITY TECHNOLOGIES LTD </option> <option value="WS">A & A A HARPER </option> <option value="SW">A & A ACCIDENT REPAIR CENTRE LTD </option> <option value="EM">A & A BUSINESS MACHINES (SERVICE) LTD </option> <option selected="selected" value="ES">A & A COWAN </option> <option value="LV">A & A DONE </option> <option value="SL">A & A MARIS </option> <option value="SM">A & A MEATS LTD </option> <option value="EA">A & A MOTOR ENGINEERS </option> <option value="ES">A & A STURROCK </option> <option value="WS">A & A TAYLOR </option> <option value="CM">A & A YOUSAF </option> <option value="WM">A & A.K. BUTTERWORTH LTD </option> <option value="WN">A & B AIR SYSTEMS LTD </option> <option value="TH">A & B AUTOS </option> <option value="NS">A & B BUCHAN </option> <option value="LW">A & B CANDY STORE </option> </select>
Whenever an item is selected where there are two items with the same value the first item is selected.
Why does .net base its selected index on the value and not the item position. Is it possible to change this?




Reply With Quote