I am using the following code to update a listbox, this recieving a list from a web service-
client.userKeywordsCompleted += new EventHandler<userKeywordsCompletedEventArgs>(client_userKeywordsCompleted);
client.userKeywordsAsync();
using -
void client_userKeywordsCompleted(object sender, userKeywordsCompletedEventArgs e)
{
string result = System.Convert.ToString(e.Result);
for (int i = 0; i < e.Result.Count; i++)
{
ListBoxItem lbitem = new ListBoxItem();
lbitem.Name = "lb_" + i;
lbitem.Content = e.Result[i];
lbitem.AddHandler(UIElement.MouseLeftButtonDownEvent, new MouseButtonEventHandler(ListBoxItem_DoubleClickEvent), true);
listBox1.Items.Add(lbitem);
}
This works fine, as I use it when the Child window loads, so the list box gets the list from the database, however when a user selects one of the items in the listbox, they have the option to edit the selected item. So one the edit is in place, there is an edit button, which updates the column in the table in the database. So then on the button click, I am again calling the aforementioned code to update the list box with the new credentials. However this brings bcak the error -
"Value does not fall within the expected range."
Why can I not call the web method on the button click, as all it is doing is refreshing the listbox???