From: JohnE on
I have a form view that when it goes to Edit I am running into an error on
any drop list. The following is a sample from one of the drop list.

'ddlEDMSCategoryID' has a SelectedValue which is invalid because it does not
exist in the list of items.

The drop list is filled using a sqldatasource. It is below;

<asp:SqlDataSource ID="EDMSCategoryEditSqlDataSource" runat="server"
ConnectionString="<%$ ConnectionStrings:ProteusConnectionString %>"
SelectCommand="SELECT EDMSCategoryID, EDMSCategory
FROM tblEDMSCategory
ORDER BY EDMSCategory ASC">
</asp:SqlDataSource>

The source code for the drop list is;

<th>EDMS Category:</th>
<td><asp:DropDownList ID="ddlEDMSCategoryID" runat="server"
DataSourceID="EDMSCategoryEditSqlDataSource"
Width="100px"
DataTextField="EDMSCategory"
DataValueField="EDMSCategoryID"
SelectedValue='<%# Bind("EDMSCategoryID") %>'>
</asp:DropDownList></td>

I am puzzled as why I am getting this. I have tested the SelectCommand in
the management studio and it returns exactly what is needed. The table
(tblChangeRequest) has the field it is bound to so it does exist.

There are records in which the field (EDMSCategoryID) in the
tblChangeRequest are empty (null). It is not necessary for a user to
complete the field for each record.

Can someone inform me as to what is missing or a way to fix this?

Thanks... John


From: JohnE on
No need to respond. I have figured out a work-a-round to the issue.
Thanks to anyone who took the time to read this post.
John



"JohnE" wrote:

> I have a form view that when it goes to Edit I am running into an error on
> any drop list. The following is a sample from one of the drop list.
>
> 'ddlEDMSCategoryID' has a SelectedValue which is invalid because it does not
> exist in the list of items.
>
> The drop list is filled using a sqldatasource. It is below;
>
> <asp:SqlDataSource ID="EDMSCategoryEditSqlDataSource" runat="server"
> ConnectionString="<%$ ConnectionStrings:ProteusConnectionString %>"
> SelectCommand="SELECT EDMSCategoryID, EDMSCategory
> FROM tblEDMSCategory
> ORDER BY EDMSCategory ASC">
> </asp:SqlDataSource>
>
> The source code for the drop list is;
>
> <th>EDMS Category:</th>
> <td><asp:DropDownList ID="ddlEDMSCategoryID" runat="server"
> DataSourceID="EDMSCategoryEditSqlDataSource"
> Width="100px"
> DataTextField="EDMSCategory"
> DataValueField="EDMSCategoryID"
> SelectedValue='<%# Bind("EDMSCategoryID") %>'>
> </asp:DropDownList></td>
>
> I am puzzled as why I am getting this. I have tested the SelectCommand in
> the management studio and it returns exactly what is needed. The table
> (tblChangeRequest) has the field it is bound to so it does exist.
>
> There are records in which the field (EDMSCategoryID) in the
> tblChangeRequest are empty (null). It is not necessary for a user to
> complete the field for each record.
>
> Can someone inform me as to what is missing or a way to fix this?
>
> Thanks... John
>
>