Hello,
I have a GridView which displays all the QccHeaders using the SelectMethod. When I select a row in the GridView a DetailsView Control becomes visible for editing. What I'm trying to do is either edit or insert data to a AuditOrgName field by selecting a item form the DropDownList which is connected to a DB table. This table has no relationship with the table that loads the GridView/DetailsView. The Problem I have is each time I click on the edit linkbutton of the DetailsView when there is data in the field I receive an error:
'AuditOrgNameDLL' has a SelectedValue which is invalid because it does not exist in the list of items. Parameter name: value. The AuditOrgName field is a nullable field in the QccHeaders table. Why is it when the field is null, Iâm able to view the DropDownList with all the items displayed from the database, select a item and update the DetailsView which will then display the newly updated data in the GridView but afterwards when returning to the row for editing I receive the error? Do I need to write some code in the code behind page? If so how do I access the DropDownList? I tried to do so in the DetailsView_Databound event but the DDL object is always null. I hope what Iâve written makes sense to you, and that you would be able to give me some pointers on this matter.
Any help would be much appreciated.
Regards,
Karl
Below is the partial asp.net markup of the page.
Code:
<asp:UpdatePanel ID="QccHeaderDetailsViewUpdatePanel" runat="server">
<ContentTemplate>
<asp:DetailsView ID="QccHeaderDetailsView" runat="server" SkinID="DetailsView"
AutoGenerateRows="False" DataKeyNames="QccHeaderID"
DataSourceID="QccHeaderDetailsViewODS"
onitemupdated="QccHeaderDetailsView_ItemUpdated">
<Fields>
<asp:TemplateField HeaderText="Audit Organization"
SortExpression="AuditOrgName" HeaderStyle-Width="25%">
<EditItemTemplate >
<asp:DropDownList ID="AuditOrgNameDDL" runat="server" Width="21%" AutoPostBack="True"
DataSourceID="AuditOrgDDLODS" DataTextField="AuditOrgName"
DataValueField="AuditOrgName" AppendDataBoundItems="True"
SelectedValue='<%# Bind("AuditOrgName") %>'>
<asp:ListItem Value="">None</asp:ListItem>
</asp:DropDownList>
<asp:ObjectDataSource ID="AuditOrgDDLODS" runat="server"
OldValuesParameterFormatString="original_{0}"
SelectMethod="GetAuditOrganization" TypeName="AuditOrganizationsBLL">
</asp:ObjectDataSource>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="AuditOrgNameLabel" runat="server" Text='<%# Bind("AuditOrgName") %>'></asp:Label>
</ItemTemplate>
<HeaderStyle Width="25%" />
</asp:TemplateField>
<asp:CommandField ShowEditButton="True" />
</Fields>
</asp:DetailsView>
<asp:ObjectDataSource ID="QccHeaderDetailsViewODS" runat="server"
OldValuesParameterFormatString="{0}"
SelectMethod="GetQccHeaderByQccHeaderID" TypeName="GetQccHeadersBLL"
UpdateMethod="UpdateQccHeader">
<UpdateParameters>
<asp:Parameter Name="auditOrgName" Type="String" />
<asp:Parameter Name="auditeeName" Type="String" />
<asp:Parameter Name="startAuditDate" Type="DateTime" />
<asp:Parameter Name="endAuditDate" Type="DateTime" />
<asp:Parameter Name="ismEditionRevision" Type="String" />
<asp:Parameter Name="regExclusion" Type="String" />
<asp:Parameter Name="exclusionTrue" Type="Boolean" />
<asp:Parameter Name="exclusionFalse" Type="Boolean" />
<asp:Parameter Name="exclusionDetails" Type="String" />
<asp:Parameter Name="piarReceivedDate" Type="DateTime" />
<asp:Parameter Name="iarReceivedDate" Type="DateTime" />
<asp:Parameter Name="piarAdminName" Type="String" />
<asp:Parameter Name="piarAdminQccDate" Type="DateTime" />
<asp:Parameter Name="piarOperName" Type="String" />
<asp:Parameter Name="piarOperQccDate" Type="DateTime" />
<asp:Parameter Name="piarStndName" Type="String" />
<asp:Parameter Name="piarStndQccDate" Type="DateTime" />
<asp:Parameter Name="iarAdminName" Type="String" />
<asp:Parameter Name="iarAdminQccDate" Type="DateTime" />
<asp:Parameter Name="iarOperName" Type="String" />
<asp:Parameter Name="iarOperQccDate" Type="DateTime" />
<asp:Parameter Name="iarStndName" Type="String" />
<asp:Parameter Name="iarStndQccDate" Type="DateTime" />
<asp:Parameter Name="qccHeaderID" Type="Int32" />
</UpdateParameters>
<SelectParameters>
<asp:ControlParameter ControlID="QccHeaderGridView" Name="qccHeaderID"
PropertyName="SelectedValue" Type="Int32" />
</SelectParameters>
</asp:ObjectDataSource>
</ContentTemplate>
</asp:UpdatePanel>