0

我的问题是如何从我的数据网格中获取选定项的项目或值,该数据网格由我的视图的 obc 填充。从我得到的结果来看,我似乎需要投射它,但我从谷歌和这里找到的所有投射都不起作用。

有人有一些提示或解决方案吗?

public partial class req: Page
    {

        DataClasses1DataContext dc = new DataClasses1DataContext();

        public requests()
        {
            InitializeComponent();
          //get from Database View  
           var query = from r in dc.requestViews select r;

            this.gridRequest.ItemsSource = new ObservableCollection<requestView>(query);
            this.gridRequest.ColumnWidth = 122.7;
        }

        private void Button_Click_1(object sender, RoutedEventArgs e)
        {
            if (gridRequest.SelectedItem == null)
            {
                MessageBox.Show("Select a Order!");
            }
            else
            {

               var qres = (from r in dc.orders where r.id.Equals(gridRequest.SelectedValue) select r).FirstOrDefault();
               qres.order_status_id = 3;
               dc.SubmitChanges();

                MessageBox.Show("Request Accepted");
                this.NavigationService.Refresh();
            }
        }
4

0 回答 0