[thelist] SOLVED: ASP.NET dropdownlist error

Joel D Canfield joel at streamliine.com
Thu Sep 27 13:16:48 CDT 2007

I was making two primary errors:

1. The field which the DDL binds to has to exist in the query for the
row of data being edited.
2. The value being bound to should be the *value* portion of the DDL,
not the visible text.

Both obvious with hindsight.

Here's what I have working:
		ID="srcDepts" runat="server" 
		ConnectionString="<%$ ConnectionStrings:cnxHelm %>"
		SelectCommand="SELECT id AS DeptID, DeptName FROM
Departments ORDER BY DeptName">
	<asp:TemplateField HeaderText="Dept" SortExpression="DeptName">
				ID="DeptDDL" runat="server" 
				SelectedValue='<%# Bind("DeptID") %>' >

Departments.id is aliased as DeptID in the query for the employee info
(what's being updated) and also in the query for the DDL, which is the
list of available values. DeptName is included in both as the visible

Thanks again for the patience and help on this.

I'll be back . . . 


More information about the thelist mailing list