5 Replies - 1448 Views - Last Post: 16 July 2009 - 02:31 PM Rate Topic: -----

#1 vloops  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 16
  • Joined: 30-April 09

Drop Down List Error

Posted 15 July 2009 - 12:49 PM

Hello all. I am using a SQL Server database to store my information and I am displaying my information using a detailsview. In one of the fields I use a literal to display information and I want to use a drop down list to edit information. When I run my program it displays the info correctly but when I try editing my field I get an error because I have a null value in that field. How do I get around this problem? I want to use my drop down list to update the field and add a value.

<asp:TemplateField HeaderText="Rank" SortExpression="RankID">
<ItemTemplate>
<asp:Literal ID="litRanks" runat="server" Text='<%# Eval("RankName") %>'></asp:Literal>
</ItemTemplate>
<EditItemTemplate>
<asp:DropDownList ID="lstAddUpRanks" runat="server" DataSourceID="SqlDataSourceAddUpRanks" DataTextField="RankName" DataValueField="RankID" SelectedValue='<%#Bind("RankID") %>'>
</asp:DropDownList>


Quote

'lstAddUpRanks' has a SelectedValue which is invalid because it does not exist in the list of items.
Parameter name: value


Is This A Good Question/Topic? 0
  • +

Replies To: Drop Down List Error

#2 CamoDeveloper  Icon User is offline

  • D.I.C Regular
  • member icon

Reputation: 20
  • View blog
  • Posts: 250
  • Joined: 12-June 09

Re: Drop Down List Error

Posted 15 July 2009 - 01:16 PM

Try making a default selected item with the value of "". I had to do that with a couple of my drop down lists.

~Camo
Was This Post Helpful? 0
  • +
  • -

#3 vloops  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 16
  • Joined: 30-April 09

Re: Drop Down List Error

Posted 15 July 2009 - 01:38 PM

View PostCamoDeveloper, on 15 Jul, 2009 - 12:16 PM, said:

Try making a default selected item with the value of "". I had to do that with a couple of my drop down lists.

~Camo



Thank you for your reply. The problem is that I pulled information from an old database into this new one. Do I have to script all the null fields to have a default value in order to get my drop down list to work?
Was This Post Helpful? 0
  • +
  • -

#4 CamoDeveloper  Icon User is offline

  • D.I.C Regular
  • member icon

Reputation: 20
  • View blog
  • Posts: 250
  • Joined: 12-June 09

Re: Drop Down List Error

Posted 16 July 2009 - 01:37 PM

Yeah, that's the only way. You could check the value in code then set it to a default if you don't want to edit your data.

~Camo
Was This Post Helpful? 0
  • +
  • -

#5 eclipsed4utoo  Icon User is offline

  • Not Your Ordinary Programmer
  • member icon

Reputation: 1524
  • View blog
  • Posts: 5,957
  • Joined: 21-March 08

Re: Drop Down List Error

Posted 16 July 2009 - 01:58 PM

View Postvloops, on 15 Jul, 2009 - 03:38 PM, said:

View PostCamoDeveloper, on 15 Jul, 2009 - 12:16 PM, said:

Try making a default selected item with the value of "". I had to do that with a couple of my drop down lists.

~Camo



Thank you for your reply. The problem is that I pulled information from an old database into this new one. Do I have to script all the null fields to have a default value in order to get my drop down list to work?


Your sql query shouldn't be sending null data anyway. It's never good to send null data. Use ISNULL in the sql query to not send null data.
Was This Post Helpful? 0
  • +
  • -

#6 vloops  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 16
  • Joined: 30-April 09

Re: Drop Down List Error

Posted 16 July 2009 - 02:31 PM

Thank you so much for your replies.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1