View Single Post
  #9 (permalink)  
Old December 1st, 2005, 05:17 PM
steve35719 steve35719 is offline
Authorized User
 
Join Date: Nov 2005
Location: , , .
Posts: 16
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Imar, I've just about had all I can stand... I did exactly as you said and keep getting:
'DropDownList1' has a SelectedValue which is invalid because it does not exist in the list of items.
Parameter name: value
Exception Details: System.ArgumentOutOfRangeException: 'DropDownList1' has a SelectedValue which is invalid because it does not exist in the list of items.
Parameter name: value

Here it is, plain and simple...

<%@ Page Language="VB" AutoEventWireup="false" CodeFile="Default.aspx.vb" Inherits="_Default" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title>Untitled Page</title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <asp:DetailsView ID="DetailsView1" runat="server" AllowPaging="True" AutoGenerateRows="False"
            DataSourceID="SqlDataSource1" Height="50px" Width="125px" DefaultMode="Edit">
            <Fields>
                <asp:BoundField DataField="Name" HeaderText="Name" SortExpression="Name" />
                <asp:TemplateField HeaderText="Color" SortExpression="Color">
                    <EditItemTemplate>
                        <asp:DropDownList ID="DropDownList1" runat="server" SelectedValue='<%# Bind("Color") %>'>
                            <asp:ListItem Selected="True">Blue</asp:ListItem>
                            <asp:ListItem>Green</asp:ListItem>
                            <asp:ListItem>Red</asp:ListItem>
                        </asp:DropDownList>
                    </EditItemTemplate>

                </asp:TemplateField>
            </Fields>
        </asp:DetailsView>
        <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:ConnectionString %>"
            SelectCommand="SELECT * FROM [Color]"
            UpdateCommand="UPDATE [Color]
                            SET Name=@Name,
                                Color=@Color
                            WHERE [Color]=@Color">
            <UpdateParameters>
                <asp:Parameter Name="Name" Type="String" />
                <asp:Parameter Name="Color" Type="string" />
            </UpdateParameters>

            </asp:SqlDataSource>

    </div>
    </form>
</body>
</html>

Does the error message have something to do with UpdateParameters? I got rid of the InsertItemTemplate and the ItemTemplate for the DetailsView and left only the EditItemTemplate.

I'm sorry to keep bothering you with this.
Greg

Reply With Quote