This is a migrated thread and some comments may be shown as answers.

[Solved] Populating a Combo Box

2 Answers 117 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
Kevin
Top achievements
Rank 1
Kevin asked on 23 Jun 2009, 09:42 AM
if i am calling a RadGrid1_SelectedIndexChanged is there a reason that if i am trying to populate a combo box that it wouldnt work?
i am calling a list and using that as a data source and data binding it to the combo box? i am also clearing the list at the start but the list is continuing to be populated when the call is finished.

 

2 Answers, 1 is accepted

Sort by
0
Kevin
Top achievements
Rank 1
answered on 23 Jun 2009, 11:39 AM
this is a code sample of what im trying to do

 protected void RadGrid1_SelectedIndexChanged(object sender, EventArgs e)  
        {  
            DateTime date;  
            if (RadCalendar1.SelectedDate == Convert.ToDateTime("01/01/0001"))  
            {  
                date = DateTime.UtcNow;  
            }  
            else 
            {  
                date = RadCalendar1.SelectedDate;  
            }  
 
            string Connection = "Data Source=62.197.41.101; Initial Catalog=PilotWebApp; User ID=sa; Pwd=medularis;";  
 
            strPropref = Request.QueryString["Propref"];  
 
            SqlConnection conn = new SqlConnection(Connection);  
            SqlCommand cmd = new SqlCommand("slot_sp_EngineerTimeslots2", conn);  
            cmd.CommandType = CommandType.StoredProcedure;  
            cmd.Parameters.AddWithValue("@PROPREF", strPropref);  
            cmd.Parameters.AddWithValue("@iSTARTDATE", date);  
            cmd.Parameters.AddWithValue("@JOBLENGTH""30");  
            cmd.Parameters.AddWithValue("@TIMESLOT", RadAppointment.SelectedValue);  
            cmd.Parameters.AddWithValue("@TIMEZONE""ALL");  
            conn.Open();  
            SqlDataReader reader = cmd.ExecuteReader();  
            DataTable dt = new DataTable();  
            dt.Load(reader);  
 
            txtEngineer.Value = RadGrid1.SelectedValue.ToString();  
 
            foreach (DataRow dr1 in dt.Rows)  
            {  
                string engineer = dr1["Engineer"].ToString();  
                int jMins = Convert.ToInt32(dr1["JobMins"]);  
                if (engineer == txtEngineer.Value)  
                {  
                    foreach (DataRow dr in dt.Rows)  
                    {  
                        string slot = Convert.ToString(dr["BookedFromTime"]).ToString();  
                        // create list item  
                        Telerik.Web.UI.RadComboBoxItem time = new Telerik.Web.UI.RadComboBoxItem(slot, slot);  
                        // add to drop down  
                        RadCboPriority.Items.Add(time);  
                    }  
                }  
            }  
        } 
0
Simon
Telerik team
answered on 24 Jun 2009, 02:33 PM
Hi Kevin,

Could you provide more details about the issue?

Do you mean that the ComboBox is populated on each postback and not just when the Grid's selected index changes?

Regards,
Simon
the Telerik team

Instantly find answers to your questions on the newTelerik Support Portal.
Check out the tipsfor optimizing your support resource searches.
Tags
ComboBox
Asked by
Kevin
Top achievements
Rank 1
Answers by
Kevin
Top achievements
Rank 1
Simon
Telerik team
Share this question
or