Link to home
Start Free TrialLog in
Avatar of HawaiiDragon
HawaiiDragon

asked on

List Box double populating

I have a new one for you guys...

I have a list box that is populated via a stored procedure .... Now here is the wierd thing my list box is being double populated... that is if I have only two names in my database where the reader is reading from i.e. Adams and Zach it is printing them ouit twice adams zach adams zach...

its like the method is being called twice...

does anyone know how to stop it from doing that???

Matt



SqlConnection con = new SqlConnection(Settings.GetConfigValue("PARK_IRB_V1_11_19_2010", "IRB2010ConnectionString"));
            con.Open();
            SqlCommand cmd = new SqlCommand("P_sp_PopulateNewFactSup", con);
            SqlDataReader r = cmd.ExecuteReader();
            DataTable dt = new DataTable();
            while (r.Read())
            {
                ListItem i = new ListItem(r["truename"].ToString().Trim(), r["ParkID"].ToString().Trim());
                LBFactSupNew.Items.Add(i);
            }
            con.Close();

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of brutaldev
brutaldev
Flag of South Africa image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of HawaiiDragon
HawaiiDragon

ASKER

I did this thank you for your help

 SqlConnection con = new SqlConnection(Settings.GetConfigValue("PARK_IRB_V1_11_19_2010", "IRB2010ConnectionString"));
            con.Open();
            SqlCommand cmd = new SqlCommand("P_sp_PopulateNewFactSup", con);
            SqlDataReader r = cmd.ExecuteReader();
            DataTable dt = new DataTable();
            LBFactSupNew.Items.Clear();
            while (r.Read())
            {
                ListItem i = new ListItem(r["truename"].ToString().Trim(), r["ParkID"].ToString().Trim());
                LBFactSupNew.Items.Add(i);
            }
            con.Close();