Hello,
I receive the error message, SelectedValue which is invalid because it does not exist in the list of items, because I have nulls in the filed that I would like to update. I have placed the bound drop-down lists to a GridView Control. I have read articles and posts about the issue and have been modifying the field properties, such as, set ConvertEmptyStringToNull=FALSE (Under the Parameter and Bound) but I am not having any success . Any Suggestions will be helpful...
The 3 Drop-down lists are bound to:
<asp:Parameter Name="UnitofIssueID" Type="String" ConvertEmptyStringToNull="False" />
<asp:Parameter Name="automake" Type="String" ConvertEmptyStringToNull="False" />
<asp:Parameter Name="ComponentClassification" Type="String" ConvertEmptyStringToNull="False" />
Exiting WebForm Code
***************************
<%@ Page Language="
VB" MasterPageFile="~/DefaultMembers.master" AutoEventWireup="false" CodeFile="subPartUpdate.aspx.
vb" Inherits="MemberPages_subPart" title="Untitled Page" %>
<asp:Content ID="Content1" ContentPlaceHolderID="Main" Runat="Server">
<h4>
Part Summary</h4>
<asp:AccessDataSource ID="PartDataSource" runat="server" DataFile="~/App_Data/Auto.mdb"
SelectCommand="SELECT * FROM [tblPart]" DeleteCommand="DELETE FROM [tblPart] WHERE [AutoAutoPartID] = ?" InsertCommand="INSERT INTO [tblPart] ([AutoAutoPartID], [UnitofIssueID], [bin], [part_number], [automake], [Auto_Stock], [part_nomenclature], [common_name], [Auto], [unit_price], [ComponentClassification], [SN_Required], [Part_SerialNumber], [RevisionPart], [RevisionDescription], [CN_Required], [ControlNumber], [Remarks], [time_stamp_entry], [time_stamp_update], [time_stamp__delete], [UserName]) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)" UpdateCommand="UPDATE [tblPart] SET [UnitofIssueID] = ?, [bin] = ?, [part_number] = ?, [automake] = ?, [Auto_Stock] = ?, [part_nomenclature] = ?, [common_name] = ?, [Auto] = ?, [unit_price] = ?, [ComponentClassification] = ?, [SN_Required] = ?, [Part_SerialNumber] = ?, [RevisionPart] = ?, [RevisionDescription] = ?, [CN_Required] = ?, [ControlNumber] = ?, [Remarks] = ?, [time_stamp_entry] = ?, [time_stamp_update] = ?, [time_stamp__delete] = ?, [UserName] = ? WHERE [AutoAutoPartID] = ?">
<DeleteParameters>
<asp:Parameter Name="AutoPartID" Type="Int32" />
</DeleteParameters>
<UpdateParameters>
<asp:Parameter Name="UnitofIssueID" Type="String" ConvertEmptyStringToNull="False" />
<asp:Parameter Name="bin" Type="String" />
<asp:Parameter Name="part_number" Type="String" />
<asp:Parameter Name="automake" Type="String" ConvertEmptyStringToNull="False" />
<asp:Parameter Name="Auto_Stock" Type="String" />
<asp:Parameter Name="part_nomenclature" Type="String" />
<asp:Parameter Name="common_name" Type="String" />
<asp:Parameter Name="AUTO" Type="Double" />
<asp:Parameter Name="unit_price" Type="Double" />
<asp:Parameter Name="ComponentClassification" Type="String" ConvertEmptyStringToNull="False" />
<asp:Parameter Name="SN_Required" Type="Boolean" />
<asp:Parameter Name="Part_SerialNumber" Type="String" />
<asp:Parameter Name="RevisionPart" Type="Boolean" />
<asp:Parameter Name="RevisionDescription" Type="String" />
<asp:Parameter Name="CN_Required" Type="Boolean" />
<asp:Parameter Name="ControlNumber" Type="String" />
<asp:Parameter Name="Remarks" Type="String" />
<asp:Parameter Name="time_stamp_entry" Type="DateTime" />
<asp:Parameter Name="time_stamp_update" Type="DateTime" />
<asp:Parameter Name="time_stamp_delete" Type="DateTime" />
<asp:Parameter Name="UserName" Type="String" />
<asp:Parameter Name="AutoPartID" Type="Int32" />
</UpdateParameters>
<InsertParameters>
<asp:Parameter Name="AutoPartID" Type="Int32" />
<asp:Parameter Name="UnitofIssueID" Type="String" ConvertEmptyStringToNull="False" />
<asp:Parameter Name="bin" Type="String" />
<asp:Parameter Name="part_number" Type="String" />
<asp:Parameter Name="automake" Type="String" ConvertEmptyStringToNull="False" />
<asp:Parameter Name="Auto_Stock" Type="String" />
<asp:Parameter Name="part_nomenclature" Type="String" />
<asp:Parameter Name="common_name" Type="String" />
<asp:Parameter Name="AUTO" Type="Double" />
<asp:Parameter Name="unit_price" Type="Double" />
<asp:Parameter Name="ComponentClassification" Type="String" ConvertEmptyStringToNull="False" />
<asp:Parameter Name="SN_Required" Type="Boolean" />
<asp:Parameter Name="Part_SerialNumber" Type="String" />
<asp:Parameter Name="RevisionPart" Type="Boolean" />
<asp:Parameter Name="RevisionDescription" Type="String" />
<asp:Parameter Name="CN_Required" Type="Boolean" />
<asp:Parameter Name="ControlNumber" Type="String" />
<asp:Parameter Name="Remarks" Type="String" />
<asp:Parameter Name="time_stamp_entry" Type="DateTime" />
<asp:Parameter Name="time_stamp_update" Type="DateTime" />
<asp:Parameter Name="time_stamp_delete" Type="DateTime" />
<asp:Parameter Name="UserName" Type="String" />
</InsertParameters>
</asp:AccessDataSource>
<asp:LinkButton ID="FinishButton" runat="server" BorderStyle="Groove" Font-Bold="True"
OnClientClick="window.opener = null; window.close()">Finished</asp:LinkButton>
<br />
<br />
<asp:GridView ID="GridView1" runat="server" AllowSorting="True" AutoGenerateColumns="False"
CellPadding="4" DataKeyNames="AutoPartID" DataSourceID="PartDataSource" ForeColor="#333333"
GridLines="None" AllowPaging="True" PageSize="500">
<FooterStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
<Columns>
<asp:CommandField ShowDeleteButton="True" ShowEditButton="True" />
<asp:BoundField DataField="AutoPartID" HeaderText="ID" InsertVisible="False" ReadOnly="True"
SortExpression="AutoPartID" />
<asp:BoundField DataField="part_number" HeaderText="Part Number" SortExpression="part_number" />
<asp:BoundField DataField="common_name" HeaderText="Common Name" SortExpression="common_name" />
<asp:BoundField DataField="part_nomenclature" HeaderText="Supply Center Part Nomen"
SortExpression="part_nomenclature" />
<asp:BoundField DataField="bin" HeaderText="BIN" SortExpression="bin" />
<asp:TemplateField ConvertEmptyStringToNull="False" HeaderText="Automake" SortExpression="automake">
<EditItemTemplate>
<asp:DropDownList ID="AutomakeDDL" runat="server" DataSourceID="automakeDDLDataSource"
DataTextField="Automake" DataValueField="Automake" SelectedValue='<%# Bind("automake") %>' AppendDataBoundItems="True">
</asp:DropDownList>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="Label1" runat="server" Text='<%# Bind("automake") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:BoundField DataField="Auto_Stock" HeaderText="Federal Stock #" SortExpression="Auto_Stock" />
<asp:BoundField DataField="unit_price" HeaderText="Unit Price" SortExpression="unit_price" />
<asp:BoundField DataField="AUTO" HeaderText="AUTO" SortExpression="AUTO" />
<asp:TemplateField ConvertEmptyStringToNull="False" HeaderText="Unit of Issue" SortExpression="UnitofIssueID">
<EditItemTemplate>
<asp:DropDownList ID="UOIDDL" runat="server" DataSourceID="UOIDDLDataSource"
DataTextField="UnitofIssueID" DataValueField="UnitofIssueID" SelectedValue='<%# Bind("UnitofIssueID") %>' AppendDataBoundItems="True">
</asp:DropDownList>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="Label2" runat="server" Text='<%# Bind("UnitofIssueID") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField ConvertEmptyStringToNull="False" HeaderText="Classification" SortExpression="ComponentClassification">
<EditItemTemplate>
<asp:DropDownList ID="ClassifyDDL" runat="server" DataSourceID="ClassifyDS"
DataTextField="ComponentClassificationID" DataValueField="ComponentClassificationID"
SelectedValue='<%# Bind("ComponentClassification") %>' AppendDataBoundItems="True">
</asp:DropDownList>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="Label3" runat="server" Text='<%# Bind("ComponentClassification") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:CheckBoxField DataField="SN_Required" HeaderText="Does This Part Have A Serial Number?"
SortExpression="SN_Required" />
<asp:BoundField DataField="Part_SerialNumber" HeaderText="Serial Number" SortExpression="Part_SerialNumber" />
<asp:CheckBoxField DataField="RevisionPart" HeaderText="Is This A Revision Part?"
SortExpression="RevisionPart" />
<asp:BoundField DataField="RevisionDescription" HeaderText="Revision Description"
SortExpression="RevisionDescription" />
<asp:CheckBoxField DataField="CN_Required" HeaderText="Does This Part Have A Control Number?"
SortExpression="CN_Required" />
<asp:BoundField DataField="ControlNumber" HeaderText="Control Number" SortExpression="ControlNumber" />
<asp:BoundField DataField="Remarks" HeaderText="Remarks" SortExpression="Remarks" />
<asp:BoundField DataField="time_stamp_entry" HeaderText="Record Created" SortExpression="time_stamp_entry" />
<asp:BoundField DataField="time_stamp_update" HeaderText="Record Last Updated" SortExpression="time_stamp_update" />
<asp:BoundField DataField="time_stamp__delete" HeaderText="Record Deleted" SortExpression="time_stamp__delete" />
<asp:BoundField DataField="UserName" HeaderText="Record Modified By" SortExpression="UserName" />
</Columns>
<RowStyle BackColor="#F7F6F3" ForeColor="#333333" />
<EditRowStyle BackColor="#999999" />
<SelectedRowStyle BackColor="#E2DED6" Font-Bold="True" ForeColor="#333333" />
<PagerStyle BackColor="#284775" ForeColor="White" HorizontalAlign="Center" />
<HeaderStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
<AlternatingRowStyle BackColor="White" ForeColor="#284775" />
</asp:GridView>
<br />
<br />
<br />
<asp:AccessDataSource ID="automakeDDLDataSource" runat="server" DataFile="~/App_Data/Auto.mdb"
SelectCommand="SELECT DISTINCT [automake] FROM [tblAutomakeRef]" CancelSelectOnNullParameter="False"></asp:AccessDataSource>
<br />
<asp:AccessDataSource ID="UOIDDLDataSource" runat="server" DataFile="~/App_Data/Auto.mdb"
SelectCommand="SELECT DISTINCT [UnitofIssueID] FROM [tblUnitofMeasure]" CancelSelectOnNullParameter="False"></asp:AccessDataSource>
<br />
<asp:AccessDataSource ID="ClassifyDS" runat="server" CacheExpirationPolicy="Sliding"
DataFile="~/App_Data/Auto.mdb" SelectCommand="SELECT DISTINCT [ComponentClassification] FROM [tblClassification]" CancelSelectOnNullParameter="False">
</asp:AccessDataSource>
<br />
<br />
<br />
</asp:Content>