troubleshooting Question

Problem with dropdown after binding arraylist

Avatar of ptslv
ptslvFlag for United States of America asked on
Web Languages and StandardsASP.NET
3 Comments1 Solution455 ViewsLast Modified:
Hi folks.  I have a dropdown that I have successfully bound to arraylist.  My problem is that when I select an option, my insert statement is showing there is no value selected.  I am querying a table for the ratings that are to populate the dropdown.  The result is a string list, so I am interating thru the list to populate the arralylist, then binding to the dropdown. Please advise.  My code is below:

bool bIsError = false;
            alRatings = new ArrayList(1); // create arraylist to hold Possible Rating Responses
            SqlConnection con = new SqlConnection(strConnection);
             string tempOption = "";
                SqlCommand cmd = con.CreateCommand();
                cmd.CommandText = "SELECT DISTINCT FormatType FROM t_Questions Where FormName= '" + formFilter + "' AND SeqNumber= " + tempSeqNum;
                SqlDataReader dr = cmd.ExecuteReader();

                if (dr.HasRows)
                    while (dr.Read())
                        tempOption = dr["FormatType"].ToString();
                    string[] strtemp = tempOption.Split(';');
                        foreach (string s in strtemp)
                    Rating.DataSource = alRatings;
            catch (Exception err)

INSERT Statement:

cmdInsert2.CommandText = "INSERT INTO t_Answers(CNTRL_NUM, Date, User, SeqNumber, " +
                        " Response, Comment)  VALUES( '" + CNTRL_NUM.Text + "', '" + Date.Text + "', '" + User.Text + "', " + SeqNumber.Text + ", '" + Rating.SelectedValue + "', '" + txtCmt.Text + "' );";
Roopesh Reddy
IT Analyst

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Top Expert 2012

The Distinguished Expert awards are presented to the top veteran and rookie experts to earn the most points in the top 50 topics.

Join our community to see this answer!
Unlock 1 Answer and 3 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 3 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros