无法绑定数据

时间:2012-05-03 04:56:26

标签: c# .net silverlight listbox windows-phone

我创建了一个WCF服务。我正在尝试在我的应用程序端实现界面。

当我在列表框中选择一个项目(食物)时,我需要获得该食物的相关卡路里。

我的表格是FOOD_TYPE,由4列组成; F_ID, FOOD, CAL_PER_SERVINGID

我哪里错了?我无法获得相关卡路里。这是我的代码。

感谢您的帮助。 MCR

private void Mybutton5_Click(object sender, RoutedEventArgs e)
    {
        Service1Client proxy = new Service1Client();
        proxy.FindCalsCompleted += new EventHandler<FindCalsCompletedEventArgs>(proxy_FindCalsCompleted);
        proxy.FindCalsAsync(String.Empty);
    }

    void proxy_FindCalsCompleted(object sender, FindCalsCompletedEventArgs e)
    {
        if (listBox1.SelectedItems.Count == 0)
        {
            MessageBox.Show("Make any food selection");
            return;
        }

        //textBox1.Text = e.Result.ToString();
        string s = "";
        for (int i = 0; i < listBox1.SelectedItems.Count; i++)
        {
            if (i == listBox1.SelectedItems.Count - 1)
                s = s + listBox1.SelectedItems[i].ToString() + e.Result;
            else
                s = s + listBox1.SelectedItems[i].ToString() + "'  or ";

        }
        s = "Calories consumed are  " +  e.Result;
        MessageBox.Show(s);

        if (listBox1.SelectedItems.Count == 0)
        {
            MessageBox.Show("Make any food selection");
            return;
        }

0 个答案:

没有答案