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

Problem with ComboBox with Image and Ajax

1 Answer 56 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
lupotana
Top achievements
Rank 1
lupotana asked on 08 Jun 2010, 01:46 PM

Hi,
I'm a RadComboBox with Image and Text.

For popolate the combo I use this method.

foreach (DataRow dr in dt.Rows)  
{  
    RadComboBoxItem item = new RadComboBoxItem(dr[descriptionColumn].ToString(), dr[codeColumn].ToString());  
        item.ImageUrl = string.Format("{0}/{1}.png", pathFolder, dr[imageColumn].ToString());  
        combo.Items.Add(item);  

It's all right, I see the image.

When I insert my combo in an UpdatePanel or RadAjaxPanel I don't view the image but an only red cross.

I suppose that Ajax doesn't succeed to open a phisical file.

Is it right? Is not possibile use ComboBox with image in an Ajax scenario ?

Thanks,
Marco

1 Answer, 1 is accepted

Sort by
0
Veronica
Telerik team
answered on 14 Jun 2010, 01:13 PM
Hello lupotana,

I've tested your case with an RadAjaxPanel. Here's the code:

protected void RadComboBox1_ItemsRequested(object o, RadComboBoxItemsRequestedEventArgs e)
    {
        RadComboBox combo = (RadComboBox)o;
        string pathFolder = "~/Images";
        SqlConnection connection =
               new SqlConnection(ConfigurationManager.ConnectionStrings["NorthwindConnectionString"].ConnectionString);
        SqlCommand selectCommand =
            new SqlCommand(@" SELECT * FROM Employees", connection);
        connection.Open();
        SqlDataAdapter adapter = new SqlDataAdapter(selectCommand);
        DataTable dt = new DataTable();
        adapter.Fill(dt);
        connection.Close();
        foreach (DataRow row in dt.Rows)
        {
            RadComboBoxItem item = new RadComboBoxItem();
            item.Text = row["FirstName"].ToString() + " " + row["LastName"].ToString();
            item.Value = row["EmployeeID"].ToString();
            item.ImageUrl = string.Format("{0}/{1}.png", pathFolder, row["LastName"].ToString());
            combo.Items.Add(item);   
        }
    }

Find the full code in the attached .zip file.

Hope this helps.

Kind regards,
Veronica Milcheva
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
Tags
ComboBox
Asked by
lupotana
Top achievements
Rank 1
Answers by
Veronica
Telerik team
Share this question
or