how to bind webservice result to listbox

Posted by Srujana under Silverlight on 3/22/2012 | Points: 10 | Views : 1916 | Status : [Member] | Replies : 3
i want to display web service result in my list box but i getting the error
what is correct procedure for binding web service result to list box
following is the my code
public partial class Antocids : PhoneApplicationPage
{
ObservableCollection<Class1> p = new ObservableCollection<Class1>();


public Antocids()
{
InitializeComponent();
listBox1.DataContext = p;
ProductsClient client = new ProductsClient();
client.getProdDetailsCompleted += new EventHandler<getProdDetailsCompletedEventArgs>(client_getProdDetailsCompleted);
client.getProdDetailsAsync();
}
private void client_getProdDetailsCompleted(object sender, getProdDetailsCompletedEventArgs e)
{


// foreach (var result in e.Result)
//p.Add(result)//i tried this also but here also i got the error
foreach(Class1 r in e.Result)// here i got the error
p.Add(r);

}




Responses

Posted by: Shravankomirineni on: 3/22/2012 [Member] Starter | Points: 25

Up
0
Down
Here have u used List collection or directly returning class obj,

Better u cane use List collection,if you return list collection,then you can directly bind to List box

Srujana, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Srujana on: 3/25/2012 [Member] Starter | Points: 25

Up
0
Down
Hi,
but i dont know exact procedure ,
can u send me a sample app

Srujana, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Vuyiswamb on: 3/30/2012 [Member] [MVP] [Administrator] NotApplicable | Points: 25

Up
0
Down
Change this to

 

foreach(Class1 r in e.Result as Class1 )
{
p.Add(r.MyFieldName);
}


Thank you for posting at Dotnetfunda
[Administrator]

Srujana, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response