Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 2.0 > ASP.NET 2.0 Basics
Password Reminder
Register
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
ASP.NET 2.0 Basics If you are new to ASP or ASP.NET programming with version 2.0, this is the forum to begin asking questions. Please also see the Visual Web Developer 2005 forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 2.0 Basics section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old February 19th, 2008, 09:26 PM
Registered User
 
Join Date: Jun 2003
Location: , , Canada.
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts
Default Cannot bind from DropDownList to DetailsView

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>
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to Bind the HTML-Textbox Value in Detailsview kcsathish ASP.NET 2.0 Basics 1 July 30th, 2008 04:34 AM
Re-Binding A Dropdownlist In A DetailsView cyber0ne BOOK: ASP.NET 2.0 Website Programming Problem Design Solution ISBN: 978-0-7645-8464-0 0 March 26th, 2007 07:10 PM
Linking two Dropdownlist in DetailsView tna55 ASP.NET 2.0 Basics 0 February 12th, 2007 10:29 AM
DropDownList in side the DetailsView ndc550 ASP.NET 2.0 Basics 0 October 19th, 2006 05:10 PM
dropdownlist value into detailsview: how? hertendreef ASP.NET 2.0 Professional 0 June 26th, 2006 01:54 AM



All times are GMT -4. The time now is 11:08 PM.


Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.