为什么数据库在删除列表框中的项目后没有刷新?

时间:2012-03-19 07:04:04

标签: windows-phone-7

为什么删除列表框中的项目后数据库没有加载?

if (result == MessageBoxResult.OK)
                {
                    int _id = int.Parse(((System.Windows.FrameworkElement)(e.OriginalSource)).Tag.ToString());
                    string strDel = "Delete from category where id=" + _id;
                    (Application.Current as App).db.Delete<Category>(strDel);


                     LoadData();

                }
在LoadData中

我绑定了items.But它在刷新后没有显示项目。

private void loaddata()
{
 string strSelect = "SELECT id,categoryid,subcategname FROM category";

            _categoryEntries = (Application.Current as App).db.SelectObservableCollection<Category>(strSelect);

            if (_categoryEntries != null)
            {
                foreach (Category data in _categoryEntries)
                {
                    switch (data.categoryid)
                    {
                        case 0:
                            app.Add(data);
                            ApplicationsListBox.ItemsSource = app;
                            break;
                     }
                }
           }
}

0 个答案:

没有答案