I am databinding a dropdown list with the following array list:
ArrayList al = new ArrayList();
al.Add(new ListItem("Service Types", 1));
al.Add(new ListItem("Expense Types", 2));
al.Add(new ListItem("Payment Terms", 3));
al.Add(new ListItem("Classes", 4));
al.Add(new ListItem("Project", 5));
al.Add(new ListItem("Employees", 6));
al.Add(new ListItem("Payroll Codes", 7));
ddlType.DataSource = al;
ddlType.DataBind();
This results in the following HTML:
<select name="ddlType">
<option value="Service Types">Service Types</option>
<option value="Expense Types">Expense Types</option>
<option value="Payment Terms">Payment Terms</option>
<option value="Classes">Classes</option>
<option value="Project">Project</option>
<option value="Employees">Employees</option>
<option value="Payroll Codes">Payroll Codes</option>
</select>
How can I set the DataTextField and DataValueField properties on my dropdown so that the values of the list items are the values in the dropdown?
Thanks.