Visual Studio .NET - asp:dropdownlist - Asked By tin tin on 21-May-05 01:05 PM

I want the dropdownlist  -
<asp:dropdownlist id="ddl1" Runat="server"></asp:dropdownlist>
to generate the html for the combo dynamically and include the "id" attribute for the list item. The final thing should like - 
<select name="_ctl3:ddl1" id="_ctl3:ddl1" >
	<option value="A" id="A">A</option>
	<option value="B" id="B">B</option>
	<option value="C" id="C">C</option>
I can set & retrieve the DataValueField, DataTextField  from a table, but what should I do to show the ID attribute for the list item and also assign a value for it from the db.
I need the id attribute to handle some functionality through javascript
Hope the question makes sense.

what you want is this: - Asked By Peter Bromberg on 21-May-05 02:04 PM

<option value="123">Customer 123</option>
where "123" is the ID column and "Customer 123" is the text value the USER SEES.
You have the DataValueField and the DataTextField for this exact purpose. The only other thing you need to do is set the DataSource to the DataTable that you want to databind to the control.

Try this and reply if works - Asked By Bharat Gambhir on 02-Jun-05 07:15 AM

try in javascript
document.getelementbyid("nameofcontrol").property="some-value"
document.getelementbyId("ddl").id="bharat"