Skip to main content

Microsoft Silverlight

Answered Question when adding items to Listbox : Value does not fall within the expected range.RSS Feed

(0)

elord
elord

Member

Member

0 points

1 Posts

when adding items to Listbox : Value does not fall within the expected range.

i'm trying to add some items to list box.

it was working before ,i made some changes and it's not working now ,

 I'm receiving a list of objects from web service (e.Result)

on the Add method i'm geting the exception:

 Value does not fall within the expected range.

 

DbFieldName is a String

            fields = e.Result;
            foreach (var item in fields)
            {
                ListBoxItem itemL = new ListBoxItem();
                itemL.Content = item.DbFieldName;
                FieldsList.Items.Add(itemL);               
            }

           

Jonathan Shen – MSFT
Jonathan...

All-Star

All-Star

24969 points

2,434 Posts

Microsoft
Answered Question

Re: when adding items to Listbox : Value does not fall within the expected range.

Hi Elord,

Based on your description, we recommend you add breakpoint to the begining of the method or fields = e.Result;  Please make sure e.Result is a collection.  If not, you'd better add breakpoints to your WebService to get the details.    By the way, you'd better first clear the ListBoxItems before you add new items if they are needs to be replaced.  Please let me know the results.

Best regards,

Jonathan

Jonathan Shen
Microsoft Online Community Support
Please remember to mark the replies as answers if they help and unmark them if they provide no help.
  • Unanswered Question
  • Answered Question
  • Announcement
Microsoft Communities