Avatar of Peter Chan
Peter Chan
Flag for Hong Kong asked on

Problem with exception

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

Microsoft AccessC#.NET ProgrammingASP.NET

Avatar of undefined
Last Comment
jorge_toriz

8/22/2022 - Mon
jorge_toriz

Are you pretty sure that in those code the exception is being raised?, I can't see any assignment to your ite2_ddl control
Peter Chan

ASKER
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

jorge_toriz

I think that ite2_ddl doen't have ite2_id in its values
Experts Exchange is like having an extremely knowledgeable team sitting and waiting for your call. Couldn't do my job half as well as I do without it!
James Murphy
Peter Chan

ASKER
No, ite2_id is the column which is from another transaction table.
ASKER CERTIFIED SOLUTION
jorge_toriz

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
Peter Chan

ASKER
Thanks.
jorge_toriz

:)
⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.