Powered by MSDN

US - English
NEW! Silverlight 5 is available Learn More

Combobox set value RSS

4 replies

Last post May 27, 2009 09:04 AM by giulia

(0)
  • giulia

    giulia

    Member

    2 Points

    8 Posts

    Combobox set value

    May 26, 2009 01:23 PM | LINK

     How can I set a default value for the combobox to display? My combobox is filled with data from a list and I need it to display one of the values from that list. I have a product and the its category is displayed in that combobox and I need that when I see the product details the category combobox value be set to the specific product category. I have tried using something like combo1.SelectedItem = "aaaa" but it doesn't work.

    Help?

  • varshavmane

    varshavmane

    Star

    13219 Points

    2753 Posts

    Re: Combobox set value

    May 26, 2009 02:08 PM | LINK

    Have you set the DisplayMemberPath, if not then set it or else post your code.

    Please "Mark as Answer" if this post answered your question. :)
    Visit my Blog
  • giulia

    giulia

    Member

    2 Points

    8 Posts

    Re: Combobox set value

    May 26, 2009 03:28 PM | LINK

    Well, I will try to explain the details of what I want to do and how I need to set that value for the combobox.

    I have a Silverlight page that shows a datagrid of products and when I select one of the product another page Silverlight is opened  and I am supposed to see the selected product details. I am sending the product id as a parameter to the new page and I get all the information needed but for the Category combobox I don't want to get only the whole list of existing categories but when the page is loaded with all the data I want to see the value I choose for the combobox and not as unselected.

    I have not used any DisplayMemberPath. I don't think it applies in my case. Specific code that could help I don't have. I just retrive the data needed from a wcf service using the product id and display all in textboxes and comboboxes.

     

  • varshavmane

    varshavmane

    Star

    13219 Points

    2753 Posts

    Re: Combobox set value

    May 27, 2009 08:34 AM | LINK

    You can first fill the combo and then set product i to it like this:

    ddlProduct.SelectedIndex = productid;

    or check this http://silverlight.net/forums/t/67956.aspx

    Hope it helps you.

    Please "Mark as Answer" if this post answered your question. :)
    Visit my Blog
  • giulia

    giulia

    Member

    2 Points

    8 Posts

    Re: Combobox set value

    May 27, 2009 09:04 AM | LINK

     Thank you! The index setting worked perfectly!