0

我将 WPF 应用程序命名为WpfApplication7.它有几个文件夹。其中之一被命名为Assign_Rights。我在此文件夹中创建了一个 UserControl 并将其命名为Assignment_Rights. 在这个用户控件中,我创建了一个网格并将其显式绑定到数据!现在按钮名称为Click New. 它向我展示PK(Primary Key-Value)selected item来自网格的信息。

User n = grid.GetRow(view.FocusedRowHandle) as User;
int abc = n.Primary_Key;

问题:当我编写代码以获取所选项目的 PK 时,它在 int abc = n.Primary_Key;

通过说

Error 'WpfApplication7.Assign_Rights.User' does not contain a definition for 'Primary_Key' and no extension method 'Primary_Key' accepting a first argument of type 'WpfApplication7.Assign_Rights.User' could be found (are you missing a using directive or an assembly reference?) D:\Backup_WPFAppliacation7\New folder\WpfApplication7\WpfApplication7\Assign_Rights\Assignment_Rights.xaml.cs 59 28 WpfApplication7

如何解决此错误?

编辑

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Data.SqlClient;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using DevExpress.Xpf.Core;
using DevExpress.Xpf.Grid;
namespace WpfApplication7.Assign_Rights
    {
    public partial class Assignment_Rights : UserControl
        {
        int useridd;
        nrcsaEntities d = new nrcsaEntities();
        public Assignment_Rights()
            {
            InitializeComponent();
           }


        private void ToggleButton1_Click_1(object sender, RoutedEventArgs e)
            {
            if (view.IsRowSelected(view.FocusedRowHandle) == false)
                {
                DXMessageBox.Show("Please Select any Item From Grid List");
                }

            else
                {

                User n = grid.GetRow(view.FocusedRowHandle) as User;
               int abc = n.Primary_Key;

                var getd = from p in d.Users select p;

                MessageBox.Show(view.FocusedRowHandle.ToString());
                } . . . .
4

0 回答 0