[thelist] ASP.NET dropdownlist error
Ken Schaefer
ken.schaefer at gmail.com
Tue Sep 25 22:28:06 CDT 2007
Hi
What does Bind("DeptName") do?
How many rows does the query you are executing return?
Cheers
Ken
On 9/26/07, Joel D Canfield <joel at streamliine.com> wrote:
> I'm trying to create a form to edit info in the SQL 2005 database. The
> code below gives me the error
>
> 'DeptDDL' has a SelectedValue which is invalid because
> it does not exist in the list of items.
> Parameter name: value
>
> when I click the automatically created 'Edit' button/link.
>
> The SQL query *does* return valid results, one of which matches
> *exactly* (no funky spaces or anything) the existing value in this row
> of data.
>
> <asp:SqlDataSource
> ID="srcDepts" runat="server"
> ConnectionString="<%$ ConnectionStrings:cnxHelm %>"
> SelectCommand="SELECT id, DeptName FROM Departments ORDER BY
> DeptName">
> </asp:SqlDataSource>
>
> <asp:TemplateField HeaderText="Dept" SortExpression="DeptName">
> <ItemTemplate>
> <%# Eval("DeptName") %>
> </ItemTemplate>
> <EditItemTemplate>
> <asp:DropDownList
> ID="DeptDDL" runat="server"
> DataSourceID="srcDepts"
> DataTextField="DeptName"
> DataValueField="id"
> AppendDataBoundItems="True"
> SelectedValue='<%# Bind("DeptName") %>'>
> </asp:DropDownList>
> </EditItemTemplate>
> </asp:TemplateField>
>
> Thoughts?
>
> joel
> --
>
> * * Please support the community that supports you. * *
> http://evolt.org/help_support_evolt/
>
> For unsubscribe and other options, including the Tip Harvester
> and archives of thelist go to: http://lists.evolt.org
> Workers of the Web, evolt !
>
More information about the thelist
mailing list