Wrox Programmer Forums
Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 2.0 > ASP.NET 2.0 Basics
| 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 software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
  #1 (permalink)  
Old October 19th, 2006, 05:10 PM
Registered User
 
Join Date: Oct 2006
Location: plano, TX, USA.
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default DropDownList in side the DetailsView

I am very new to dotnet 2.0 and I need alot of help. In the DetailsView EditItemTemplate I have a dropdownlist which i have problem with when I click on the Update button. The error message that I got is:
"'DropDownList2' has a SelectedValue which is invalid because it does not exist in the list of items. Parameter name: value ".

If I leave out the "SelectedValue='<%# Bind("") %>" from the tag then the edit mode displayed ok.

Thanks very much,
Loi.

Here is my code:


<asp:DetailsView ID="DetailsView1" runat="server" AllowPaging="True" AutoGenerateRows="False"
            DataKeyNames="iSurveyQuestionid" DataSourceID="SqlDataSource2" Height="50px"
            OnItemInserting="DetailsView1_ItemInserting"
            OnItemUpdating="DetailsView1_ItemUpdating"
            OnDataBound="DetailsView1_DataBound"
            CellPadding="4" ForeColor="#333333"
            Width="100%">
            <Fields>
                <asp:BoundField DataField="iSurveyQuestionid" HeaderText="iSurveyQuestionid" InsertVisible="False"
                    ReadOnly="True" Visible="False" SortExpression="iSurveyQuestionid" />
                <asp:TemplateField HeaderText="Physical Question" SortExpression="vchPhysicalQuestion">
                    <EditItemTemplate>
                        <asp:TextBox ID="TextBox1" runat="server" TextMode="MultiLine" Text='<%# Bind("vchPhysicalQuestion") %>'></asp:TextBox>
                    </EditItemTemplate>
                    <InsertItemTemplate>
                        <asp:TextBox ID="TextBox1" runat="server" TextMode="MultiLine" Text='<%# Bind("vchPhysicalQuestion") %>'></asp:TextBox>
                    </InsertItemTemplate>
                    <ItemTemplate>
                        <asp:Label ID="Label1" runat="server" Text='<%# Bind("vchPhysicalQuestion") %>'></asp:Label>
                    </ItemTemplate>
                    <HeaderStyle Width="20%" />
                </asp:TemplateField>
                <asp:TemplateField HeaderText="chQuestionType" SortExpression="chQuestionType">
                    <EditItemTemplate>
                        <asp:DropDownList ID="DropDownList2" runat="server" SelectedValue='<%# Bind("chQuestionType") %>'>
                            <asp:ListItem Value="S">Single</asp:ListItem>
                            <asp:ListItem Value="M">Multiple</asp:ListItem>
                            <asp:ListItem Value="T">Text</asp:ListItem>
                        </asp:DropDownList>
                    </EditItemTemplate>
                    <InsertItemTemplate>
                        <asp:DropDownList ID="DropDownList3" runat="server" SelectedValue='<%# Bind("chQuestionType") %>'>
                            <asp:ListItem Value="S">Single</asp:ListItem>
                            <asp:ListItem Value="M">Multiple</asp:ListItem>
                            <asp:ListItem Value="T">Text</asp:ListItem>
                        </asp:DropDownList>
                    </InsertItemTemplate>
                    <ItemTemplate>
                        <asp:Label ID="Label2" runat="server" Text='<%# Bind("chQuestionType") %>'></asp:Label>
                    </ItemTemplate>
                </asp:TemplateField>
                <asp:BoundField Visible="False" DataField="iSurveyid" HeaderText="iSurveyid" SortExpression="iSurveyid" />
                <asp:CommandField ShowDeleteButton="True" ShowEditButton="True" ShowInsertButton="True" />
            </Fields>
        </asp:DetailsView>


The label displayed the value of "S" when I first load the page.




Similar Threads
Thread Thread Starter Forum Replies Last Post
Accessing DropDownList in DetailsView firblazer ASP.NET 3.5 Basics 2 June 21st, 2008 06:48 AM
Cannot bind from DropDownList to DetailsView kiekar ASP.NET 2.0 Basics 0 February 19th, 2008 09:26 PM
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 value into detailsview: how? hertendreef ASP.NET 2.0 Professional 0 June 26th, 2006 01:54 AM





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