'DropDownList1' has a SelectedValue which is invalid because it does not exist in the list of itemshttp://forums.asp.net/t/1056921.aspx/1?+DropDownList1+has+a+SelectedValue+which+is+invalid+because+it+does+not+exist+in+the+list+of+itemsWed, 03 Feb 2010 22:03:36 -050010569211506375http://forums.asp.net/p/1056921/1506375.aspx/1?+DropDownList1+has+a+SelectedValue+which+is+invalid+because+it+does+not+exist+in+the+list+of+items'DropDownList1' has a SelectedValue which is invalid because it does not exist in the list of items <p>Friends being a newbie in asp.net&nbsp;I have been layin my hands on this problem for quiet sometime now...hope I find my answer here..</p> <p>First things first..</p> <p>I have a&nbsp;gridview which &nbsp;is bound to a SQLDatasource1.In the gridview we have two dropdown(dropdownlist1 and dropdownlist2) Template fields.</p> <p>Now one of the template field is bound to a datasource SQL datasource2 while the other contains a list of data hardcoded.</p> <p>Now my requirement is to update the datasource bound to the gridview with the data selectd with the dropdownlist.</p> <p>Now the dropdownlist&nbsp;is bound to&nbsp;a column called vendorname contained in vendormaster table.</p> <p>The gridview is bound to a table called request which also contains a column called vendorname..however this column is empty..ie has no data in any row..simply ' '.........</p> <p>My requirement is to b able to update the request table by selecting values from the two dropdownlist in the gridview..instead i end up with this error...</p> <p>&quot;'DropDownList2' has a SelectedValue which is invalid because it does not exist in the list of items&quot;</p> <p>After going thru&nbsp;a few posts I understand that its due&nbsp;&quot;no values&quot; present in the &quot;request&quot; table for &quot;vendormaster&quot; column.&nbsp;</p> <p>I then tried hardcodin the values for dropdownlist1 as i have for dropdownlist2..Interesting it now gives the same error for dropdownlist2....</p> <p>when i removed dropdownlist2 from the gridview things work abs fine....but guys I need to have both the dropdownlist and above that I need to bind my dropdwnlist1 to a datasource.......</p> <p>How do I accomplish this update....any help wll b highly apreciated..here is the part&nbsp;my code.......&nbsp;</p> <font color="#0000ff" size="2"> <p>&lt;</font><font color="#800000" size="2">asp</font><font color="#0000ff" size="2">:</font><font color="#800000" size="2">GridView</p> </font><font size="2"> <p></font><font color="#ff0000" size="2">ID</font><font color="#0000ff" size="2">=&quot;GridView1&quot;</font><font size="2"> </font><font color="#ff0000" size="2">runat</font><font color="#0000ff" size="2">=&quot;server&quot;</font><font size="2"> </font><font color="#ff0000" size="2">Style</font><font color="#0000ff" size="2">=&quot;left: 0px; position: relative; top: -87px&quot;</p> </font><font size="2"> <p></font><font color="#ff0000" size="2">Width</font><font color="#0000ff" size="2">=&quot;550px&quot;</font><font size="2"> </font><font color="#ff0000" size="2">AutoGenerateEditButton</font><font color="#0000ff" size="2">=&quot;True&quot;</font><font size="2"> </font><font color="#ff0000" size="2">AutoGenerateColumns</font><font color="#0000ff" size="2">=&quot;False&quot;</font><font size="2"> </font><font color="#ff0000" size="2">DataSourceID</font><font color="#0000ff" size="2">=&quot;SqlDataSource2&quot;</font><font size="2"> </font><font color="#ff0000" size="2">BackColor</font><font color="#0000ff" size="2">=&quot;#DEBA84&quot;</font><font size="2"> </font><font color="#ff0000" size="2">BorderColor</font><font color="#0000ff" size="2">=&quot;#DEBA84&quot;</font><font size="2"> </font><font color="#ff0000" size="2">BorderStyle</font><font color="#0000ff" size="2">=&quot;None&quot;</font><font size="2"> </font><font color="#ff0000" size="2">BorderWidth</font><font color="#0000ff" size="2">=&quot;1px&quot;</font><font size="2"> </font><font color="#ff0000" size="2">CellPadding</font><font color="#0000ff" size="2">=&quot;3&quot;</font><font size="2"> </font><font color="#ff0000" size="2">CellSpacing</font><font color="#0000ff" size="2">=&quot;2&quot;</font><font size="2"> </font><font color="#ff0000" size="2">Height</font><font color="#0000ff" size="2">=&quot;190px&quot;&gt;</p> </font><font size="2"> <p></font><font color="#0000ff" size="2">&lt;</font><font color="#800000" size="2">Columns</font><font color="#0000ff" size="2">&gt;</p> </font><font size="2"> <p></font><font color="#0000ff" size="2">&lt;</font><font color="#800000" size="2">asp</font><font color="#0000ff" size="2">:</font><font color="#800000" size="2">BoundField</font><font size="2"> </font><font color="#ff0000" size="2">DataField</font><font color="#0000ff" size="2">=&quot;AssetName&quot;</font><font size="2"> </font><font color="#ff0000" size="2">HeaderText</font><font color="#0000ff" size="2">=&quot;AssetName&quot;</font><font size="2"> </font><font color="#ff0000" size="2">SortExpression</font><font color="#0000ff" size="2">=&quot;AssetName&quot;</font><font size="2"> </font><font color="#0000ff" size="2">/&gt;</p> </font><font size="2"> <p></font><font color="#0000ff" size="2">&lt;</font><font color="#800000" size="2">asp</font><font color="#0000ff" size="2">:</font><font color="#800000" size="2">BoundField</font><font size="2"> </font><font color="#ff0000" size="2">DataField</font><font color="#0000ff" size="2">=&quot;Units&quot;</font><font size="2"> </font><font color="#ff0000" size="2">HeaderText</font><font color="#0000ff" size="2">=&quot;Units&quot;</font><font size="2"> </font><font color="#ff0000" size="2">SortExpression</font><font color="#0000ff" size="2">=&quot;Units&quot;</font><font size="2"> </font><font color="#0000ff" size="2">/&gt;</p> </font><font size="2"> <p></font><font color="#0000ff" size="2">&lt;</font><font color="#800000" size="2">asp</font><font color="#0000ff" size="2">:</font><font color="#800000" size="2">BoundField</font><font size="2"> </font><font color="#ff0000" size="2">DataField</font><font color="#0000ff" size="2">=&quot;RequestDescription&quot;</font><font size="2"> </font><font color="#ff0000" size="2">ReadOnly</font><font color="#0000ff" size="2">=&quot;True&quot;</font><font size="2"> </font><font color="#ff0000" size="2">HeaderText</font><font color="#0000ff" size="2">=&quot;RequestDescription&quot;</font><font size="2"> </font><font color="#ff0000" size="2">SortExpression</font><font color="#0000ff" size="2">=&quot;RequestDescription&quot;</font><font size="2"> </font><font color="#0000ff" size="2">/&gt;</p> </font><font size="2"> <p></font><font color="#0000ff" size="2">&lt;</font><font color="#800000" size="2">asp</font><font color="#0000ff" size="2">:</font><font color="#800000" size="2">TemplateField</font><font size="2"> </font><font color="#ff0000" size="2">HeaderText</font><font color="#0000ff" size="2">=&quot;VendorName&quot;&gt;</p> </font><font size="2"> <p></font><font color="#0000ff" size="2">&lt;</font><font color="#800000" size="2">EditItemTemplate</font><font color="#0000ff" size="2">&gt;</p> </font><font size="2"> <p></font><font color="#0000ff" size="2">&lt;</font><font color="#800000" size="2">asp</font><font color="#0000ff" size="2">:</font><font color="#800000" size="2">DropDownList</font><font size="2"> </font><font color="#ff0000" size="2">ID</font><font color="#0000ff" size="2">=&quot;DropDownList1&quot;</font><font size="2"> </font><font color="#ff0000" size="2">runat</font><font color="#0000ff" size="2">=&quot;server&quot;</font><font size="2"> </font><font color="#ff0000" size="2">Style</font><font color="#0000ff" size="2">=&quot;position: relative&quot;</font><font size="2"> </font><font color="#ff0000" size="2">Width</font><font color="#0000ff" size="2">=&quot;94px&quot;/&gt;</p> </font><font size="2"> <p></font><font color="#0000ff" size="2">&lt;</font><font color="#800000" size="2">asp</font><font color="#0000ff" size="2">:</font><font color="#800000" size="2">SqlDataSource</font><font size="2"> </font><font color="#ff0000" size="2">ID</font><font color="#0000ff" size="2">=&quot;SqlDataSource3&quot;</font><font size="2"> </font><font color="#ff0000" size="2">runat</font><font color="#0000ff" size="2">=&quot;server&quot;</font><font size="2"> </font><font color="#ff0000" size="2">ConnectionString</font><font color="#0000ff" size="2">=&quot;</font><font size="2">&lt;%&#36; ConnectionStrings:inventoryConnectionString %&gt;</font><font color="#0000ff" size="2">&quot;</p> </font><font size="2"> <p></font><font color="#0000ff" size="2">' SelectCommand=&quot;SELECT [VendorName] FROM [VendorMaster]&quot;&gt;&lt;/</font><font color="#800000" size="2">asp</font><font color="#0000ff" size="2">:</font><font color="#800000" size="2">SqlDataSource</font><font color="#0000ff" size="2">&gt;</font><font size="2"> </p> <p>&nbsp;</p> <p></font><font color="#0000ff" size="2">&lt;/</font><font color="#800000" size="2">EditItemTemplate</font><font color="#0000ff" size="2">&gt;</p> </font><font size="2"> <p></font><font color="#0000ff" size="2">&lt;/</font><font color="#800000" size="2">asp</font><font color="#0000ff" size="2">:</font><font color="#800000" size="2">TemplateField</font><font color="#0000ff" size="2">&gt;</p> </font><font size="2"> <p></font><font color="#0000ff" size="2">&lt;</font><font color="#800000" size="2">asp</font><font color="#0000ff" size="2">:</font><font color="#800000" size="2">TemplateField</font><font size="2"> </font><font color="#ff0000" size="2">HeaderText</font><font color="#0000ff" size="2">=&quot;Status&quot;&gt;</p> </font><font size="2"> <p></font><font color="#0000ff" size="2">&lt;</font><font color="#800000" size="2">EditItemTemplate</font><font color="#0000ff" size="2">&gt;</p> </font><font size="2"> <p>' </font><font color="#0000ff" size="2">&lt;</font><font color="#800000" size="2">asp</font><font color="#0000ff" size="2">:</font><font color="#800000" size="2">DropDownList</font><font size="2"> </font><font color="#ff0000" size="2">ID</font><font color="#0000ff" size="2">=&quot;DropDownList2&quot;</font><font size="2"> </font><font color="#ff0000" size="2">runat</font><font color="#0000ff" size="2">=&quot;server&quot;</font><font size="2"> </font><font color="#ff0000" size="2">Style</font><font color="#0000ff" size="2">=&quot;position: relative&quot;</font><font size="2"> </font><font color="#ff0000" size="2">Width</font><font color="#0000ff" size="2">=&quot;39px&quot;</font><font size="2"> </font><font color="#ff0000" size="2">selectedvalue</font><font color="#0000ff" size="2">='</font><font size="2">&lt;%# Bind(&quot;Status&quot;) %&gt;</font><font color="#0000ff" size="2">'&gt;</p> </font><font size="2"> <p>' </font><font color="#0000ff" size="2">&lt;</font><font color="#800000" size="2">asp</font><font color="#0000ff" size="2">:</font><font color="#800000" size="2">ListItem</font><font color="#0000ff" size="2">&gt;&lt;/</font><font color="#800000" size="2">asp</font><font color="#0000ff" size="2">:</font><font color="#800000" size="2">ListItem</font><font color="#0000ff" size="2">&gt;</p> </font><font size="2"> <p>' </font><font color="#0000ff" size="2">&lt;</font><font color="#800000" size="2">asp</font><font color="#0000ff" size="2">:</font><font color="#800000" size="2">ListItem</font><font size="2"> </font><font color="#ff0000" size="2">Value</font><font color="#0000ff" size="2">=&quot;A&quot;&gt;&lt;/</font><font color="#800000" size="2">asp</font><font color="#0000ff" size="2">:</font><font color="#800000" size="2">ListItem</font><font color="#0000ff" size="2">&gt;</p> </font><font size="2"> <p>' </font><font color="#0000ff" size="2">&lt;</font><font color="#800000" size="2">asp</font><font color="#0000ff" size="2">:</font><font color="#800000" size="2">ListItem</font><font size="2"> </font><font color="#ff0000" size="2">Value</font><font color="#0000ff" size="2">=&quot;P&quot;&gt;&lt;/</font><font color="#800000" size="2">asp</font><font color="#0000ff" size="2">:</font><font color="#800000" size="2">ListItem</font><font color="#0000ff" size="2">&gt;</p> </font><font size="2"> <p>' </font><font color="#0000ff" size="2">&lt;</font><font color="#800000" size="2">asp</font><font color="#0000ff" size="2">:</font><font color="#800000" size="2">ListItem</font><font size="2"> </font><font color="#ff0000" size="2">Value</font><font color="#0000ff" size="2">=&quot;D&quot;&gt;&lt;/</font><font color="#800000" size="2">asp</font><font color="#0000ff" size="2">:</font><font color="#800000" size="2">ListItem</font><font color="#0000ff" size="2">&gt;</p> </font><font size="2"> <p>' </font><font color="#0000ff" size="2">&lt;/</font><font color="#800000" size="2">asp</font><font color="#0000ff" size="2">:</font><font color="#800000" size="2">DropDownList</font><font color="#0000ff" size="2">&gt;</font><font size="2"> </p> <p>' </font><font color="#0000ff" size="2">&lt;/</font><font color="#800000" size="2">EditItemTemplate</font><font color="#0000ff" size="2">&gt;</p> </font><font size="2"> <p></font><font color="#0000ff" size="2">&lt;/</font><font color="#800000" size="2">asp</font><font color="#0000ff" size="2">:</font><font color="#800000" size="2">TemplateField</font><font color="#0000ff" size="2">&gt;</p> </font><font size="2"> <p>&nbsp;</p> <p>&nbsp;</p> <p></font><font color="#0000ff" size="2">&lt;/</font><font color="#800000" size="2">Columns</font><font color="#0000ff" size="2">&gt;</p> </font><font size="2"> <p></font><font color="#0000ff" size="2">&lt;/</font><font color="#800000" size="2">asp</font><font color="#0000ff" size="2">:</font><font color="#800000" size="2">GridView</font><font color="#0000ff" size="2">&gt;</p> </font><font size="2"> <p></font><font color="#0000ff" size="2">&lt;</font><font color="#800000" size="2">asp</font><font color="#0000ff" size="2">:</font><font color="#800000" size="2">SqlDataSource</font><font size="2"> </font><font color="#ff0000" size="2">ID</font><font color="#0000ff" size="2">=&quot;SqlDataSource3&quot;</font><font size="2"> </font><font color="#ff0000" size="2">runat</font><font color="#0000ff" size="2">=&quot;server&quot;</font><font size="2"> </font><font color="#ff0000" size="2">ConnectionString</font><font color="#0000ff" size="2">=&quot;</font><font size="2">&lt;%&#36; ConnectionStrings:inventoryConnectionString %&gt;</font><font color="#0000ff" size="2">&quot;</font><font size="2"> </font><font color="#ff0000" size="2">SelectCommand</font><font color="#0000ff" size="2">=&quot;SELECT [VendorName] FROM [VendorMaster]&quot;&gt;&lt;/</font><font color="#800000" size="2">asp</font><font color="#0000ff" size="2">:</font><font color="#800000" size="2">SqlDataSource</font><font color="#0000ff" size="2">&gt;</p> </font><font size="2"> <p></font><font color="#0000ff" size="2">&lt;</font><font color="#800000" size="2">asp</font><font color="#0000ff" size="2">:</font><font color="#800000" size="2">SqlDataSource</font><font size="2"> </font><font color="#ff0000" size="2">ID</font><font color="#0000ff" size="2">=&quot;SqlDataSource1&quot;</font><font size="2"> </font><font color="#ff0000" size="2">runat</font><font color="#0000ff" size="2">=&quot;server&quot;</font><font size="2"> </font><font color="#ff0000" size="2">ConnectionString</font><font color="#0000ff" size="2">=&quot;</font><font size="2">&lt;%&#36; ConnectionStrings:inventoryConnectionString %&gt;</font><font color="#0000ff" size="2">&quot;</p> </font><font size="2"> <p></font><font color="#ff0000" size="2">SelectCommand</font><font color="#0000ff" size="2">=&quot;SELECT DISTINCT [OrderNumber] FROM [Requisition] WHERE ([Status] &amp;lt;&amp;gt; @Status)&quot;&gt;</p> </font><font size="2"> <p></font><font color="#0000ff" size="2">&lt;</font><font color="#800000" size="2">SelectParameters</font><font color="#0000ff" size="2">&gt;</p> </font><font size="2"> <p></font><font color="#0000ff" size="2">&lt;</font><font color="#800000" size="2">asp</font><font color="#0000ff" size="2">:</font><font color="#800000" size="2">Parameter</font><font size="2"> </font><font color="#ff0000" size="2">DefaultValue</font><font color="#0000ff" size="2">=&quot;A&quot;</font><font size="2"> </font><font color="#ff0000" size="2">Name</font><font color="#0000ff" size="2">=&quot;Status&quot;</font><font size="2"> </font><font color="#ff0000" size="2">Type</font><font color="#0000ff" size="2">=&quot;String&quot;</font><font size="2"> </font><font color="#0000ff" size="2">/&gt;</p> </font><font size="2"> <p></font><font color="#0000ff" size="2">&lt;/</font><font color="#800000" size="2">SelectParameters</font><font color="#0000ff" size="2">&gt;</p> </font><font size="2"> <p></font><font color="#0000ff" size="2">&lt;/</font><font color="#800000" size="2">asp</font><font color="#0000ff" size="2">:</font><font color="#800000" size="2">SqlDataSource</font><font color="#0000ff" size="2">&gt;</p> </font><font size="2"> <p></font><font color="#0000ff" size="2">&lt;</font><font color="#800000" size="2">asp</font><font color="#0000ff" size="2">:</font><font color="#800000" size="2">SqlDataSource</font><font size="2"> </font><font color="#ff0000" size="2">ID</font><font color="#0000ff" size="2">=&quot;SqlDataSource2&quot;</font><font size="2"> </font><font color="#ff0000" size="2">runat</font><font color="#0000ff" size="2">=&quot;server&quot;</font><font size="2"> </font><font color="#ff0000" size="2">ConnectionString</font><font color="#0000ff" size="2">=&quot;</font><font size="2">&lt;%&#36; ConnectionStrings:inventoryConnectionString %&gt;</font><font color="#0000ff" size="2">&quot;</p> </font><font size="2"> <p></font><font color="#ff0000" size="2">SelectCommand</font><font color="#0000ff" size="2">=&quot;SELECT [AssetName], [Units], [VendorName], [RequestDescription], [Status] FROM [Requisition] WHERE (([OrderNumber] = @OrderNumber) AND ([Status] &amp;lt;&amp;gt; @Status))&quot;</p> </font><font size="2"> <p></font><font color="#ff0000" size="2">UpdateCommand</font><font color="#0000ff" size="2">=&quot;UPDATE [Requisition] SET [Units]=@Units,[VendorName]=@VendorName,[Status]=@Status WHERE (([OrderNumber] = @OrderNumber) AND ([AssetName] = @AssetName))&quot;&gt;</p> </font><font size="2"> <p></font><font color="#0000ff" size="2">&lt;</font><font color="#800000" size="2">SelectParameters</font><font color="#0000ff" size="2">&gt;</p> </font><font size="2"> <p></font><font color="#0000ff" size="2">&lt;</font><font color="#800000" size="2">asp</font><font color="#0000ff" size="2">:</font><font color="#800000" size="2">ControlParameter</font><font size="2"> </font><font color="#ff0000" size="2">ControlID</font><font color="#0000ff" size="2">=&quot;DropDownList1&quot;</font><font size="2"> </font><font color="#ff0000" size="2">Name</font><font color="#0000ff" size="2">=&quot;OrderNumber&quot;</font><font size="2"> </font><font color="#ff0000" size="2">PropertyName</font><font color="#0000ff" size="2">=&quot;SelectedValue&quot;</p> </font><font size="2"> <p></font><font color="#ff0000" size="2">Type</font><font color="#0000ff" size="2">=&quot;Int32&quot;</font><font size="2"> </font><font color="#0000ff" size="2">/&gt;</p> </font><font size="2"> <p></font><font color="#0000ff" size="2">&lt;</font><font color="#800000" size="2">asp</font><font color="#0000ff" size="2">:</font><font color="#800000" size="2">Parameter</font><font size="2"> </font><font color="#ff0000" size="2">DefaultValue</font><font color="#0000ff" size="2">=&quot;A&quot;</font><font size="2"> </font><font color="#ff0000" size="2">Name</font><font color="#0000ff" size="2">=&quot;Status&quot;</font><font size="2"> </font><font color="#ff0000" size="2">Type</font><font color="#0000ff" size="2">=&quot;String&quot;</font><font size="2"> </font><font color="#0000ff" size="2">/&gt;</p> </font><font size="2"> <p></font><font color="#0000ff" size="2">&lt;/</font><font color="#800000" size="2">SelectParameters</font><font color="#0000ff" size="2">&gt;</p> </font><font size="2"> <p></font><font color="#0000ff" size="2">&lt;</font><font color="#800000" size="2">UpdateParameters</font><font color="#0000ff" size="2">&gt;</p> </font><font size="2"> <p></font><font color="#0000ff" size="2">&lt;</font><font color="#800000" size="2">asp</font><font color="#0000ff" size="2">:</font><font color="#800000" size="2">ControlParameter</font><font size="2"> </font><font color="#ff0000" size="2">ControlID</font><font color="#0000ff" size="2">=&quot;DropDownList1&quot;</font><font size="2"> </font><font color="#ff0000" size="2">Name</font><font color="#0000ff" size="2">=&quot;OrderNumber&quot;</font><font size="2"> </font><font color="#ff0000" size="2">PropertyName</font><font color="#0000ff" size="2">=&quot;SelectedValue&quot;</p> </font><font size="2"> <p></font><font color="#ff0000" size="2">Type</font><font color="#0000ff" size="2">=&quot;Int32&quot;</font><font size="2"> </font><font color="#0000ff" size="2">/&gt;</p> </font><font size="2"> <p>&nbsp;</p> <p></font><font color="#0000ff" size="2">&lt;</font><font color="#800000" size="2">asp</font><font color="#0000ff" size="2">:</font><font color="#800000" size="2">Parameter</font><font size="2"> </font><font color="#ff0000" size="2">Name</font><font color="#0000ff" size="2">=&quot;VendorName&quot;</font><font size="2"> </font><font color="#ff0000" size="2">ConvertEmptyStringToNull</font><font color="#0000ff" size="2">=&quot;false&quot;</font><font size="2"> </font><font color="#ff0000" size="2">Type</font><font color="#0000ff" size="2">=&quot;String&quot;</font><font size="2"> </font><font color="#0000ff" size="2">/&gt;</p> </font><font size="2"> <p></font><font color="#0000ff" size="2">&lt;</font><font color="#800000" size="2">asp</font><font color="#0000ff" size="2">:</font><font color="#800000" size="2">Parameter</font><font size="2"> </font><font color="#ff0000" size="2">Name</font><font color="#0000ff" size="2">=&quot;Status&quot;</font><font size="2"> </font><font color="#ff0000" size="2">ConvertEmptyStringToNull</font><font color="#0000ff" size="2">=&quot;false&quot;</font><font size="2"> </font><font color="#ff0000" size="2">Type</font><font color="#0000ff" size="2">=&quot;Char&quot;</font><font size="2"> </font><font color="#0000ff" size="2">/&gt;</p> </font><font size="2"> <p></font><font color="#0000ff" size="2">&lt;</font><font color="#800000" size="2">asp</font><font color="#0000ff" size="2">:</font><font color="#800000" size="2">Parameter</font><font size="2"> </font><font color="#ff0000" size="2">Name</font><font color="#0000ff" size="2">=&quot;AssetName&quot;</font><font size="2"> </font><font color="#ff0000" size="2">Type</font><font color="#0000ff" size="2">=&quot;String&quot;</font><font size="2"> </font><font color="#0000ff" size="2">/&gt;</p> </font><font size="2"> <p></font><font color="#0000ff" size="2">&lt;</font><font color="#800000" size="2">asp</font><font color="#0000ff" size="2">:</font><font color="#800000" size="2">Parameter</font><font size="2"> </font><font color="#ff0000" size="2">Name</font><font color="#0000ff" size="2">=&quot;Units&quot;</font><font size="2"> </font><font color="#ff0000" size="2">Type</font><font color="#0000ff" size="2">=&quot;Int32&quot;</font><font size="2"> </font><font color="#0000ff" size="2">/&gt;</p> </font><font size="2"> <p>&nbsp;</p> <p></font><font color="#0000ff" size="2">&lt;/</font><font color="#800000" size="2">UpdateParameters</font><font color="#0000ff" size="2">&gt;</p> </font><font size="2"> <p>&nbsp;</p> <p></font><font color="#0000ff" size="2">&lt;/</font><font color="#800000" size="2">asp</font><font color="#0000ff" size="2">:</font><font color="#800000" size="2">SqlDataSource</font><font color="#0000ff" size="2">&gt;</p> </font> <p>Thanx in advance[:)]</p> 2006-12-22T10:36:27-05:001506541http://forums.asp.net/p/1056921/1506541.aspx/1?Re+DropDownList1+has+a+SelectedValue+which+is+invalid+because+it+does+not+exist+in+the+list+of+itemsRe: 'DropDownList1' has a SelectedValue which is invalid because it does not exist in the list of items <p>Here is an example of a dropdown list from one of my sites that has it's selection values populated from 1 datasource but it's SelectValue is bound to another.</p> <font color="#0000ff" size="2"> <p>&lt;</font><font color="#a31515" size="2">asp</font><font color="#0000ff" size="2">:</font><font color="#a31515" size="2">DropDownList</font><font size="2"> </font><font color="#ff0000" size="2">ID</font><font color="#0000ff" size="2">=&quot;ddlPCModel&quot;</font><font size="2"> </font><font color="#ff0000" size="2">runat</font><font color="#0000ff" size="2">=&quot;server&quot;</font><font size="2"> </font><font color="#ff0000" size="2">DataSourceID</font><font color="#0000ff" size="2">=&quot;sqldsPCLookup&quot;</font><font size="2"> </font><font color="#ff0000" size="2">DataTextField</font><font color="#0000ff" size="2">=&quot;Model&quot;</p> </font><font size="2"> <p></font><font color="#ff0000" size="2">DataValueField</font><font color="#0000ff" size="2">=&quot;Model&quot;</font><font size="2"> </font><font color="#ff0000" size="2">SelectedValue</font><font color="#0000ff" size="2">='</font><font size="2">&lt;%# Bind(&quot;PCModel&quot;) %&gt;</font><font color="#0000ff" size="2">'&gt;</p> </font> 2006-12-22T14:13:57-05:001507199http://forums.asp.net/p/1056921/1507199.aspx/1?Re+DropDownList1+has+a+SelectedValue+which+is+invalid+because+it+does+not+exist+in+the+list+of+itemsRe: 'DropDownList1' has a SelectedValue which is invalid because it does not exist in the list of items <font color="#0000ff" size="2"> <p>I tried using the following code..</p> <p>&lt;</font><font color="#800000" size="2">asp</font><font color="#0000ff" size="2">:</font><font color="#800000" size="2">DropDownList</font><font size="2"> </font><font color="#ff0000" size="2">ID</font><font color="#0000ff" size="2">=&quot;DropDownList1&quot;</font><font size="2"> </font><font color="#ff0000" size="2">runat</font><font color="#0000ff" size="2">=&quot;server&quot;</font><font size="2"> </font><font color="#ff0000" size="2">Style</font><font color="#0000ff" size="2">=&quot;position: relative&quot;</font><font size="2"> </font><font color="#ff0000" size="2">Width</font><font color="#0000ff" size="2">=&quot;94px&quot;</font><font size="2"> </font><font color="#ff0000" size="2">DataSourceID</font><font color="#0000ff" size="2">=&quot;SqlDataSource3&quot;</font><font size="2"> </font><font color="#ff0000" size="2">DataTextField</font><font color="#0000ff" size="2">=&quot;VendorName&quot;</font><font size="2"> </font><font color="#ff0000" size="2">DataValueField</font><font color="#0000ff" size="2">=&quot;VendorName&quot;</font><font size="2"> </font><font color="#ff0000" size="2">SelectedValue</font><font color="#0000ff" size="2">='</font><font size="2">&lt;%# Bind(&quot;VendorName&quot;) %&gt;</font><font color="#0000ff" size="2">'/&gt;</font><font size="2"> </font></p> <p><font size="2">still the same problem....</font></p> <p>I think this is hapenning due to the empty string values in the&nbsp;Vendorname column that has been bound to the dropdownlist1.....</p> <p>I need to replace these empty cells with the data selected from the dropdownlist...</p> <p>Do i need to write some code for gridview_Itemdatabound or gridview_ItemUpdating&nbsp;to tackle this issue....</p> <p>Thanx...</p> <p>&nbsp;</p> <p>&nbsp;</p> <p>&nbsp;</p> <p><font size="2">&nbsp;</p> </font> 2006-12-23T04:49:05-05:001508033http://forums.asp.net/p/1056921/1508033.aspx/1?Re+DropDownList1+has+a+SelectedValue+which+is+invalid+because+it+does+not+exist+in+the+list+of+itemsRe: 'DropDownList1' has a SelectedValue which is invalid because it does not exist in the list of items <p>Hi, <strong>brazen:</strong>&nbsp;</p> <p>This is quite a problem if you have not maintained data integrity, and/or if your Select statment in your dropdownlist data source does not include particular values. </p> <p>Plz have a look at this article and amend your datasource to have a valid datasets.</p> <p><a href="http://www.wherecanibuyit.co.uk/ASP/advanced_gridview_with_edit_and_insert_part_3.html">http://www.wherecanibuyit.co.uk/ASP/advanced_gridview_with_edit_and_insert_part_3.html</a><br> </p> 2006-12-25T06:48:31-05:001518376http://forums.asp.net/p/1056921/1518376.aspx/1?Re+DropDownList1+has+a+SelectedValue+which+is+invalid+because+it+does+not+exist+in+the+list+of+itemsRe: 'DropDownList1' has a SelectedValue which is invalid because it does not exist in the list of items <p>I get this same error but the URL Link provided does not help with my scenerio. When I go to edit bindings form my user control The Binding for visible fields are &quot;greyed out&quot; including the two-way databinding.</p> <p>I have a form view edit item template. I have a user control that makes up two dropdownlists. The user control has two properties that return the slected value.</p> <p>Cany anyone provide some insight on how to do this through the source code?</p> 2007-01-04T15:21:47-05:001527762http://forums.asp.net/p/1056921/1527762.aspx/1?Re+DropDownList1+has+a+SelectedValue+which+is+invalid+because+it+does+not+exist+in+the+list+of+itemsRe: 'DropDownList1' has a SelectedValue which is invalid because it does not exist in the list of items <p>I&nbsp;too get this error - my data set IS valid and frustratingly it works sometimes (!)</p> <p>I have found redoing the dropdownlist on the page sometimes corrects the problem, as occasionally does refreshing the schema, but I am trying to complete a form with 6 of these on and it's like juggling plates - am I doing something wrong? why does it seem so flaky?</p> <p>Sorry to not offer insight just saying I've got the same problem...</p> 2007-01-11T11:27:51-05:001527855http://forums.asp.net/p/1056921/1527855.aspx/1?Re+DropDownList1+has+a+SelectedValue+which+is+invalid+because+it+does+not+exist+in+the+list+of+itemsRe: 'DropDownList1' has a SelectedValue which is invalid because it does not exist in the list of items <p>MS and many coders say this is the correct behaviour, to the rest of us normal people its just a stupid pain in the arse that we could do without.</p> <p>&nbsp;I add a null to the select command eg &quot;select cola, colb from table1 union select null, null&quot;</p> <p>Or you can populate the ddl via code, this is VB:</p> <p>&nbsp;&nbsp; Dim strCON As String, sqlCON As SqlConnection<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Dim strSQL As String, sqlCOM As SqlCommand, sqlDRD As SqlDataReader</p> <p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; strCON = ConfigurationManager.ConnectionStrings(&quot;con_db_TM&quot;).ToString<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; sqlCON = New SqlConnection(strCON)</p> <p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; sqlCON.Open()</p> <p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; strSQL = &quot;select distinct tr_code_sub from dbo.tbl_transactions &quot; &amp; _<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &quot;where tr_code = '&quot; &amp; Me.ddlCode.SelectedValue &amp; &quot;'&quot;</p> <p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; sqlCOM = New SqlCommand(strSQL, sqlCON)<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; sqlDRD = sqlCOM.ExecuteReader</p> <p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Me.ddlCodeSub.Items.Clear()<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Me.ddlCodeSub.Items.Add(&quot;&quot;)</p> <p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; With sqlDRD<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; If .HasRows = True Then<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; While .Read<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Me.ddlCodeSub.Items.Add(.Item(0))<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; End While<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; End If<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; End With</p> <p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; sqlDRD.Close()<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; sqlCON.Close()<br> </p> 2007-01-11T12:34:42-05:001527983http://forums.asp.net/p/1056921/1527983.aspx/1?Re+DropDownList1+has+a+SelectedValue+which+is+invalid+because+it+does+not+exist+in+the+list+of+itemsRe: 'DropDownList1' has a SelectedValue which is invalid because it does not exist in the list of items <p>It works &quot;sometimes&quot; because it can find the value both in the dropdownlist and the table your are binding your details view or form view to.&nbsp;</p> <p>Let's say you have a dropdownlist with numbers 1 - 9. Then&nbsp;your form view or details view is bound to the data table so you can have the &quot;selected value&quot; displayed when you edit a record. When you view various records some have 1 - 9 in the data table and it can find the value in the dropdownlist and show it as the selected value. Lets say the next record has a 10 or a 0 or is Null, then it can't find a value to show as selected.</p> <p>I think MS assumes that all db have referential integrity. There are many legacy databases that are not perfect.</p> <p>So really there are two ways to get by this issue that I've found in the past few week. Either clean up your data in the database and fix all the relationship's or use a user control for the dropdownlist in your application. See this thread for more help with the user control. <a href="http://forums.asp.net/thread/1518715.aspx">http://forums.asp.net/thread/1518715.aspx</a>&nbsp;</p> 2007-01-11T13:59:20-05:001670581http://forums.asp.net/p/1056921/1670581.aspx/1?Re+DropDownList1+has+a+SelectedValue+which+is+invalid+because+it+does+not+exist+in+the+list+of+itemsRe: 'DropDownList1' has a SelectedValue which is invalid because it does not exist in the list of items <p>Hi There</p> <p>&nbsp;I've recently come to asp.2 from 1.1 and am still finding my way. I'm getting the same problem 'dropdownlist has a selected value which is invalid' problem. I have basically added a yes and no text value with corresponding 1 and 0 values to the dropdown list. i've bound the value field to the datasource to reflect a binary column field. I'm sorry but i just do not see why this will not work as the value&nbsp;very clearly exists in the list. any ideas on this?</p> 2007-04-18T08:49:50-04:001671047http://forums.asp.net/p/1056921/1671047.aspx/1?Re+DropDownList1+has+a+SelectedValue+which+is+invalid+because+it+does+not+exist+in+the+list+of+itemsRe: 'DropDownList1' has a SelectedValue which is invalid because it does not exist in the list of items Check to make sure that data table doesn't have blank or null values.&nbsp; All records in the data table should have a 1 or a 0 in the column bound to the drop down. 2007-04-18T13:45:20-04:001690411http://forums.asp.net/p/1056921/1690411.aspx/1?Re+DropDownList1+has+a+SelectedValue+which+is+invalid+because+it+does+not+exist+in+the+list+of+itemsRe: 'DropDownList1' has a SelectedValue which is invalid because it does not exist in the list of items <p>Thanks DetroitJ</p> <p>Your first posts help me the most.&nbsp; this one. </p> <p>&gt;&gt;Here is an example of a dropdown list from one of my sites that has it's selection values populated from 1 datasource but it's SelectValue is bound to another.</p> <font color="#0000ff" size="2"> <p>see above...</font></p> <p><font size="3">If you are new, some of the posts about this error are quite confusing.&nbsp; I just created a new table in the database that my Dropdown could pull from.&nbsp; a very simple table.</font></p> <p><font size="3">two columns although only one column would have been enough for my situation.&nbsp; </font></p> <p><font size="3">like this </font></p> <p><font size="3">id&nbsp;&nbsp; Locationname</font></p> <p><font size="3">1&nbsp; Unassigned</font></p> <p><font size="3">2&nbsp; Location1</font></p> <p><font size="3">3 Location2</font></p> <p><font size="3">4 Location3</font></p> <p>Now like what DetroitJ said&nbsp; the list is pulled from our new table but saves the data to the main table. The GenLoc (stands for General Location) is in the main table I am saving to.&nbsp;LocationName is from our new table. &nbsp;</p> <font color="#0000ff" size="2"> <p>&lt;</font><font color="#800000" size="2">asp</font><font color="#0000ff" size="2">:</font><font color="#800000" size="2">DropDownList</font><font size="2"> </font><font color="#ff0000" size="2">ID</font><font color="#0000ff" size="2">=&quot;DDGenLoc&quot;</font><font size="2"> </font><font color="#ff0000" size="2">runat</font><font color="#0000ff" size="2">=&quot;server&quot;</font><font size="2"> </font><font color="#ff0000" size="2">DataSourceID</font><font color="#0000ff" size="2">=&quot;SqlDS_GenlOcation&quot;</font><font size="2"> </font><font color="#ff0000" size="2">DataTextField</font><font color="#0000ff" size="2">=&quot;LocationName&quot;</font><font size="2"> </font><font color="#ff0000" size="2">DataValueField</font><font color="#0000ff" size="2">=&quot;LocationName&quot;</font><font size="2"> </font><font color="#ff0000" size="2">SelectedValue</font><font color="#0000ff" size="2">='</font><font size="2">&lt;%# Bind(&quot;GenLoc&quot;) %&gt;</font><font color="#0000ff" size="2">'&gt;</p> </font><font size="2"> <p></font><font color="#0000ff" size="2">&lt;/</font><font color="#800000" size="2">asp</font><font color="#0000ff" size="2">:</font><font color="#800000" size="2">DropDownList</font><font color="#0000ff" size="2">&gt;</p> </font> <p><font size="3">the </font><font color="#0000ff" size="2">SqlDS_GenlOcation data adapter just selects the items in this small table above</font></p> <p><font color="#0000ff">but the selectedValue is bound to the table that does not have values in it yet.&nbsp; </font></p> <p><font color="#0000ff"><font color="#ff0000">Both DataTextField</font><font color="#0000ff" size="2">=&quot;LocationName&quot;</font><font color="#000000" size="2"> </font><font color="#ff0000" size="2">DataValueField</font><font color="#0000ff" size="2">=&quot;LocationName&quot;&nbsp; (so the first column is not necessary for me, because I am using a dataform.&nbsp; I am already in the record.) </font></font></p> <p><font color="#0000ff">Then I put this in the code behind</font></p> <font size="2"> <p></font><font color="#0000ff" size="2">Protected</font><font size="2"> </font><font color="#0000ff" size="2">Sub</font><font size="2"> FVWorkspace_DataBound(</font><font color="#0000ff" size="2">ByVal</font><font size="2"> sender </font><font color="#0000ff" size="2">As</font><font size="2"> </font><font color="#0000ff" size="2">Object</font><font size="2">, </font><font color="#0000ff" size="2">ByVal</font><font size="2"> e </font><font color="#0000ff" size="2">As</font><font size="2"> System.EventArgs) </font><font color="#0000ff" size="2">Handles</font><font size="2"> FVWorkspace.DataBound</p> <p></font><font color="#0000ff" size="2">If</font><font size="2"> </font><font color="#0000ff" size="2">Me</font><font size="2">.FVWorkspace.CurrentMode = FormViewMode.Edit </font><font color="#0000ff" size="2">Then</p> </font> <p><font color="#0000ff" size="2">Dim</font><font size="2"> ddl </font><font color="#0000ff" size="2">As</font><font size="2"> DropDownList = </font><font color="#0000ff" size="2">CType</font><font size="2">(</font><font color="#0000ff" size="2">Me</font><font size="2">.FVWorkspace.FindControl(</font><font color="#800000" size="2">&quot;DDGenLoc&quot;</font><font size="2">), DropDownList)</p> <p>ddl.Items.Insert(0, </font><font color="#0000ff" size="2">New</font><font size="2"> ListItem(</font><font color="#800000" size="2">&quot;Unassigned&quot;</font><font size="2">, </font><font color="#800000" size="2">&quot;0&quot;</font><font size="2">))</p> <p></font><font color="#0000ff" size="2">End</font><font size="2"> </font><font color="#0000ff" size="2">If</font></p> <p><font color="#0000ff" size="2">End</font><font size="2"> </font><font color="#0000ff" size="2">Sub</font></p> <p><font color="#0000ff" size="2">Also in my main table I populated the entire GenLoc column with the string &quot;Unassigned&quot;&nbsp; well only where the rows do not have values.</font></p> <p><font color="#0000ff">This is the easiest way out of this mess.&nbsp; If you can't beat it join it. put the data it wants in the tables. </font></p> <p><font color="#0000ff">forget the if null then crap.&nbsp; Its a pain.&nbsp; </font></p> <p><font color="#0000ff"></font>&nbsp;</p> <p><font color="#0000ff"></font>&nbsp;</p> <p><font color="#0000ff"></font>&nbsp;</p> <p><font color="#0000ff"></font>&nbsp;</p> <p><font color="#0000ff"></font>&nbsp;</p> <p><font color="#0000ff"></font>&nbsp;</p> <p><font color="#0000ff" size="2">&nbsp;</p> </font> <p><font size="3"></font>&nbsp;</p> <p><font size="3"></font>&nbsp;</p> <p><font size="3"></font>&nbsp;</p> 2007-05-01T21:59:34-04:001690419http://forums.asp.net/p/1056921/1690419.aspx/1?Re+DropDownList1+has+a+SelectedValue+which+is+invalid+because+it+does+not+exist+in+the+list+of+itemsRe: 'DropDownList1' has a SelectedValue which is invalid because it does not exist in the list of items <p>I take part of that back. </p> <p>&nbsp;You do not even need that code behind section.</p> <p>just delete<font size="2"></p> <p></font><font color="#0000ff" size="2">Protected</font><font size="2"> </font><font color="#0000ff" size="2">Sub</font><font size="2"> FVWorkspace_DataBound(</font><font color="#0000ff" size="2">ByVal</font><font size="2"> sender </font><font color="#0000ff" size="2">As</font><font size="2"> </font><font color="#0000ff" size="2">Object</font><font size="2">, </font><font color="#0000ff" size="2">ByVal</font><font size="2"> e </font><font color="#0000ff" size="2">As</font><font size="2"> System.EventArgs) </font><font color="#0000ff" size="2">Handles</font><font size="2"> FVWorkspace.DataBound</p> <p></font><font color="#0000ff" size="2">If</font><font size="2"> </font><font color="#0000ff" size="2">Me</font><font size="2">.FVWorkspace.CurrentMode = FormViewMode.Edit </font><font color="#0000ff" size="2">Then</p> </font><font size="2"> <p>Response.Write(</font><font color="#800000" size="2">&quot;test&quot;</font><font size="2">)</p> <p></font><font color="#0000ff" size="2">Dim</font><font size="2"> ddl </font><font color="#0000ff" size="2">As</font><font size="2"> DropDownList = </font><font color="#0000ff" size="2">CType</font><font size="2">(</font><font color="#0000ff" size="2">Me</font><font size="2">.FVWorkspace.FindControl(</font><font color="#800000" size="2">&quot;DDGenLoc&quot;</font><font size="2">), DropDownList)</p> <p>ddl.Items.Insert(0, </font><font color="#0000ff" size="2">New</font><font size="2"> ListItem(</font><font color="#800000" size="2">&quot;Unassigned&quot;</font><font size="2">, </font><font color="#800000" size="2">&quot;0&quot;</font><font size="2">))</p> <p></font><font color="#0000ff" size="2">End</font><font size="2"> </font><font color="#0000ff" size="2">If</p> </font> 2007-05-01T22:05:02-04:001766249http://forums.asp.net/p/1056921/1766249.aspx/1?Re+DropDownList1+has+a+SelectedValue+which+is+invalid+because+it+does+not+exist+in+the+list+of+itemsRe: 'DropDownList1' has a SelectedValue which is invalid because it does not exist in the list of items <p>Hi,</p> <p>I encountered the same problem today but I think there is another more elegant solution than updating all the tables. Having a null value in a column is a common requirement.<br> All the list controls have a property called AppendDataBoundItems which is a boolean. If you set it to true than all the items that you add to the control before data binding will be preserved.<br> So in our case I think we could do something like:</p> <p>&lt;asp:DropDownList ID=&quot;Category&quot; runat=&quot;server&quot; AppendDataBoundItems=&quot;true&quot;&gt;<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;asp:ListItem Text=&quot;Please select&quot; Value=&quot;&quot; /&gt;<br> &lt;/asp:DropDownList&gt;<br> &nbsp;<br> After you databind the control you'll still have the Please select item.<br> I didnt try it yet but I think this is the way to go around null values. I'll give it a try and let you know.<br> Regarding broken foreign keys, you might want to write custom code to handle it.<br> <br> Cosmin.<br> &nbsp;</p> <p>&nbsp;</p> 2007-06-21T17:04:18-04:001836276http://forums.asp.net/p/1056921/1836276.aspx/1?Re+DropDownList1+has+a+SelectedValue+which+is+invalid+because+it+does+not+exist+in+the+list+of+itemsRe: 'DropDownList1' has a SelectedValue which is invalid because it does not exist in the list of items <p>I solved&nbsp;this issue on my project by making my i<font color="#a31515">temTemplate</font> and EditItemTempates bound to different names</p> <font size="2"> <p></font><font color="#0000ff" size="2">&lt;</font><font color="#a31515" size="2">asp</font><font color="#0000ff" size="2">:</font><font color="#a31515" size="2">TemplateField</font><font size="2"> </font><font color="#ff0000" size="2">HeaderText</font><font color="#0000ff" size="2">=&quot;Room&quot;</font><font size="2"> </font><font color="#ff0000" size="2">SortExpression</font><font color="#0000ff" size="2">=&quot;Room&quot;&gt;</p> </font><font size="2"> <p></font><font color="#0000ff" size="2">&lt;</font><font color="#a31515" size="2">EditItemTemplate</font><font color="#0000ff" size="2">&gt;</p> </font><font size="2"></font><font color="#0000ff" size="2">&lt;</font><font color="#a31515" size="2">asp</font><font color="#0000ff" size="2">:</font><font color="#a31515" size="2">DropDownList</font><font size="2"> </font><font color="#ff0000" size="2">ID</font><font color="#0000ff" size="2">=&quot;ddlRoom&quot;</font><font size="2"> </font><font color="#ff0000" size="2">runat</font><font color="#0000ff" size="2">=&quot;server&quot;</font><font size="2"> </font><font size="2"> <p></font><font color="#ff0000" size="2">DataSourceID</font><font color="#0000ff" size="2">=&quot;SqlDataRoom&quot;</font><font size="2"> </p> </font><font color="#ff0000" size="2">SelectedValue</font><font color="#0000ff" size="2">='</font><font size="2">&lt;%# Bind(&quot;TRAINING_ROOM&quot;) %&gt;</font><font color="#0000ff" size="2">'</font><font size="2"> </font><font size="2"> <p></font><font color="#ff0000" size="2">DataTextField</font><font color="#0000ff" size="2">=&quot;ROOM&quot;</font><font size="2"> </font><font color="#ff0000" size="2">DataValueField</font><font color="#0000ff" size="2">=&quot;ROW_ID&quot;</p> </font><font size="2"></font><font color="#ff0000" size="2">Font-Names</font><font color="#0000ff" size="2">=&quot;Verdana&quot;</font><font size="2"> </font><font color="#ff0000" size="2">Font-Size</font><font color="#0000ff" size="2">=&quot;X-Small&quot;</font><font size="2"> </font><font color="#ff0000" size="2">Width</font><font color="#0000ff" size="2">=&quot;175px&quot;</font><font size="2"> </font><font size="2"> <p></font><font color="#ff0000" size="2">AppendDataBoundItems</font><font color="#0000ff" size="2">=&quot;true&quot;&gt;</p> </font><font size="2"> <p></font><font color="#0000ff" size="2">&lt;</font><font color="#a31515" size="2">asp</font><font color="#0000ff" size="2">:</font><font color="#a31515" size="2">ListItem</font><font size="2"> </font><font color="#ff0000" size="2">Value</font><font color="#0000ff" size="2">=&quot;&quot;&gt;</font><font size="2">(--Select One--)</font><font color="#0000ff" size="2">&lt;/</font><font color="#a31515" size="2">asp</font><font color="#0000ff" size="2">:</font><font color="#a31515" size="2">ListItem</font><font color="#0000ff" size="2">&gt;</p> </font><font size="2"> <p></font><font color="#0000ff" size="2">&lt;/</font><font color="#a31515" size="2">asp</font><font color="#0000ff" size="2">:</font><font color="#a31515" size="2">DropDownList</font><font color="#0000ff" size="2">&gt;</p> </font><font size="2"> <p></font><font color="#0000ff" size="2">&lt;/</font><font color="#a31515" size="2">EditItemTemplate</font><font color="#0000ff" size="2">&gt;</p> </font><font size="2"> <p></font><font color="#0000ff" size="2">&lt;</font><font color="#a31515" size="2">ItemStyle</font><font size="2"> </font><font color="#ff0000" size="2">Width</font><font color="#0000ff" size="2">=&quot;250px&quot;</font><font size="2"> </font><font color="#0000ff" size="2">/&gt;</p> </font><font size="2"> <p></font><font color="#0000ff" size="2">&lt;</font><font color="#a31515" size="2">ItemTemplate</font><font color="#0000ff" size="2">&gt;</p> </font><font size="2"> <p></font><font color="#0000ff" size="2">&lt;</font><font color="#a31515" size="2">asp</font><font color="#0000ff" size="2">:</font><font color="#a31515" size="2">Label</font><font size="2"> </font><font color="#ff0000" size="2">ID</font><font color="#0000ff" size="2">=&quot;lblRoomName&quot;</font><font size="2"> </font><font color="#ff0000" size="2">runat</font><font color="#0000ff" size="2">=&quot;server&quot;</font><font size="2"> </font><font color="#ff0000" size="2">Text</font><font color="#0000ff" size="2">='</font><font size="2">&lt;%# Bind(&quot;ROOM_NAME&quot;) %&gt;</font><font color="#0000ff" size="2">'&gt;&lt;/</font><font color="#a31515" size="2">asp</font><font color="#0000ff" size="2">:</font><font color="#a31515" size="2">Label</font><font color="#0000ff" size="2">&gt;</p> </font><font size="2"> <p></font><font color="#0000ff" size="2">&lt;/</font><font color="#a31515" size="2">ItemTemplate</font><font color="#0000ff" size="2">&gt;</p> </font><font size="2"> <p></font><font color="#0000ff" size="2">&lt;/</font><font color="#a31515" size="2">asp</font><font color="#0000ff" size="2">:</font><font color="#a31515" size="2">TemplateField</font><font color="#0000ff" size="2">&gt;</p> </font><font color="#0000ff" size="2"></font> 2007-08-01T22:37:54-04:002298545http://forums.asp.net/p/1056921/2298545.aspx/1?Re+DropDownList1+has+a+SelectedValue+which+is+invalid+because+it+does+not+exist+in+the+list+of+itemsRe: 'DropDownList1' has a SelectedValue which is invalid because it does not exist in the list of items <p>I fixed this issue by setting up my DropDownList like this:<br> </p> <pre class="prettyprint">&lt;asp:DropDownList ID=&quot;DropDownList2&quot; runat=&quot;server&quot; DataSourceID=&quot;ReferralDataSource&quot; DataTextField=&quot;FieldValue&quot; DataValueField=&quot;LookupId&quot; Enabled=&quot;False&quot; SelectedValue='&lt;%# Bind(&quot;ReferralSource&quot;) %&gt;' AppendDataBoundItems=&quot;True&quot;&gt; &lt;asp:ListItem Value=&quot;0&quot;&gt;Please Select&lt;/asp:ListItem&gt; &lt;/asp:DropDownList&gt;</pre>Then setting the default value in the database to 0, which sets the default selected item to &quot;Please Select&quot;<br> <p>&nbsp;</p> 2008-04-15T10:25:00-04:002302705http://forums.asp.net/p/1056921/2302705.aspx/1?Re+DropDownList1+has+a+SelectedValue+which+is+invalid+because+it+does+not+exist+in+the+list+of+itemsRe: 'DropDownList1' has a SelectedValue which is invalid because it does not exist in the list of items <p>&nbsp;look over this code in detail to see the changes... Add the changes to your code and see if this works... it sound like you have vaules in your table that are Null or have no value, so in the dropdown list i added &lt;asp:ListItem Value=&quot;&quot;&gt;Select&lt;/asp:ListItem&gt;&nbsp;. The word Select will be the default that shows at the top of the list with a value of Nothing. See the Value=&quot;&quot;. I hope this helps.</p> <p>&lt;asp:DropDownList ID=&quot;DropDownList2&quot; runat=&quot;server&quot; Style=&quot;position: relative&quot; Width=&quot;39px&quot; selectedvalue='&lt;%# Bind(&quot;Status&quot;) %&gt;' AppendDataBoundItems=&quot;True&quot;&gt; </p> <p>&lt;asp:ListItem&gt;&lt;/asp:ListItem&gt; </p> <p>&lt;asp:ListItem Value=&quot;&quot;&gt;Select&lt;/asp:ListItem&gt; </p> <p>&lt;asp:ListItem Value=&quot;A&quot;&gt;&lt;/asp:ListItem&gt; </p> <p>&lt;asp:ListItem Value=&quot;P&quot;&gt;&lt;/asp:ListItem&gt; </p> <p>&lt;asp:ListItem Value=&quot;D&quot;&gt;&lt;/asp:ListItem&gt;&nbsp; </p> <p>&lt;/asp:DropDownList&gt; </p> 2008-04-16T22:05:16-04:002302708http://forums.asp.net/p/1056921/2302708.aspx/1?Re+DropDownList1+has+a+SelectedValue+which+is+invalid+because+it+does+not+exist+in+the+list+of+itemsRe: 'DropDownList1' has a SelectedValue which is invalid because it does not exist in the list of items also, pay attention to the AppendDataBoundItems=&quot;True&quot; do not for get to add that to you code. 2008-04-16T22:07:01-04:002302716http://forums.asp.net/p/1056921/2302716.aspx/1?Re+DropDownList1+has+a+SelectedValue+which+is+invalid+because+it+does+not+exist+in+the+list+of+itemsRe: 'DropDownList1' has a SelectedValue which is invalid because it does not exist in the list of items <p>mhlove, Thanks for the suggestion,&nbsp;I did check that too--it's set</p> 2008-04-16T22:11:58-04:002302720http://forums.asp.net/p/1056921/2302720.aspx/1?Re+DropDownList1+has+a+SelectedValue+which+is+invalid+because+it+does+not+exist+in+the+list+of+itemsRe: 'DropDownList1' has a SelectedValue which is invalid because it does not exist in the list of items <p>mhlove--thanks for the suggestion, unfortunately null or blank values are not my problem--this is still in design phase, I only have 5 recs in the database, trust me, no nulls or blanks in the field I'm using.&nbsp; I think I'm going to tear it down and start again--amazingly that works a lot with .NET (from the same folks who brought you Shut Down--Reboot in Windows!&nbsp; [:)]</p> <p>&nbsp;</p> 2008-04-16T22:14:06-04:002576605http://forums.asp.net/p/1056921/2576605.aspx/1?Re+DropDownList1+has+a+SelectedValue+which+is+invalid+because+it+does+not+exist+in+the+list+of+itemsRe: 'DropDownList1' has a SelectedValue which is invalid because it does not exist in the list of items <p>Personally I think the best solution is to check the items that are being bound to the DropDownList to ensure your value is in there.</p> <p>There is an article&nbsp;showing this method here:</p> <p><a href="http://blog.evonet.com.au/post/2008/06/07/dropdownlist1-has-a-SelectedValue-which-is-invalid-because-it-does-not-exist-in-the-list-of-items.aspx">http://blog.evonet.com.au/post/2008/06/07/dropdownlist1-has-a-SelectedValue-which-is-invalid-because-it-does-not-exist-in-the-list-of-items.aspx</a></p> <p>Cheers,</p> <p>Bartek&nbsp;</p> <p>&nbsp;</p> 2008-08-24T01:56:31-04:00