[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

Problem with exception

Posted on 2013-12-05
8
Medium Priority
?
540 Views
Last Modified: 2013-12-05
Hi,
I get this error

Server Error in '/App18_devst' Application.

'ite2_ddl' has a SelectedValue which is invalid because it does not exist in the list of items.
Parameter name: value
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.ArgumentOutOfRangeException: 'ite2_ddl' has a SelectedValue which is invalid because it does not exist in the list of items.
Parameter name: value

Source Error:


An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

Stack Trace:



[ArgumentOutOfRangeException: 'ite2_ddl' has a SelectedValue which is invalid because it does not exist in the list of items.
Parameter name: value]
   System.Web.UI.WebControls.ListControl.set_SelectedValue(String value) +12587357
   App18._Default.refresh_pg() +6112
   App18._Default.lb_edt_Click(Object sender, EventArgs e) +86
   System.Web.UI.WebControls.LinkButton.RaisePostBackEvent(String eventArgument) +153
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +3804

 


Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.18408

due to the codes below. why?
            conn.Open();
            try
            {
                cmd = new OleDbCommand("SELECT a.id,a.fld_name FROM ite1 a,ite2 b where ite2_name=b.fld_name and b.fld_name=@ite2 order by 1", conn);

                cmd.Parameters.Add("@ite2", OleDbType.VarChar).Value = ite2_ddl.SelectedValue;
                reader = cmd.ExecuteReader();
                ite1_ddl.Items.Add(new ListItem("Please select", "0"));
                while (reader.Read())
                {
                    ite1_ddl.Items.Add(new ListItem(reader[1].ToString(), reader[0].ToString()));
                }
            }
            ...

Open in new window

0
Comment
Question by:HuaMinChen
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 3
8 Comments
 
LVL 15

Expert Comment

by:jorge_toriz
ID: 39699669
Are you pretty sure that in those code the exception is being raised?, I can't see any assignment to your ite2_ddl control
0
 
LVL 11

Author Comment

by:HuaMinChen
ID: 39700008
Many thanks all.
Jorge,
here is the part I can see in the whole project, that is having an assignment to ite2_ddl.
                    if (reader["ite2_id"] != null)
                    {
                        if (reader["ite2_id"] != DBNull.Value)
                        {
                            ite2_ddl.ClearSelection();
                            ite2_ddl.SelectedValue = Convert.ToString(reader["ite2_id"]);
                        }
                    }

Open in new window

0
 
LVL 15

Expert Comment

by:jorge_toriz
ID: 39700022
I think that ite2_ddl doen't have ite2_id in its values
0
Get your Disaster Recovery as a Service basics

Disaster Recovery as a Service is one go-to solution that revolutionizes DR planning. Implementing DRaaS could be an efficient process, easily accessible to non-DR experts. Learn about monitoring, testing, executing failovers and failbacks to ensure a "healthy" DR environment.

 
LVL 11

Author Comment

by:HuaMinChen
ID: 39700029
No, ite2_id is the column which is from another transaction table.
0
 
LVL 15

Accepted Solution

by:
jorge_toriz earned 620 total points
ID: 39700041
Yes, I mean that this line:

ite2_ddl.SelectedValue = Convert.ToString(reader["ite2_id"]);

It's (probably) causing the error, you need the reader["ite2_id"] value on your DropDownList to be able to set as SelectedValue
0
 
LVL 11

Author Comment

by:HuaMinChen
ID: 39700054
Thanks.
0
 
LVL 15

Expert Comment

by:jorge_toriz
ID: 39700097
:)
0

Featured Post

 [eBook] Windows Nano Server

Download this FREE eBook and learn all you need to get started with Windows Nano Server, including deployment options, remote management
and troubleshooting tips and tricks

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The Windows Phone Theme Colours is a tight, powerful, and well balanced palette. This tiny Access application makes it a snap to select and pick a value. And it doubles as an intro to implementing WithEvents, one of Access' hidden gems.
Traditionally, the method to display pictures in Access forms and reports is to first download them from URLs to a folder, record the path in a table and then let the form or report pull the pictures from that folder. But why not let Windows retr…
With Microsoft Access, learn how to specify relationships between tables and set various options on the relationship. Add the tables: Create the relationship: Decide if you’re going to set referential integrity: Decide if you want cascade upda…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …
Suggested Courses

649 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question