本文介绍了无法启用此约束,因为并非所有值都在c#中具有相应的父值?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我尝试在嵌套的gridview中填充数据。我收到此错误无法启用此约束,因为并非所有值都具有相应的父值。我的错误是什么?帮帮我解决这个问题。 这是我的代码
I tried to populate data's in nested gridview. Am getting this error This constraint cannot be enabled as not all values have corresponding parent values. What is my error ? Help me to solve this. This is my code
validateDept.InitializeConnection(); OleDbConnection connection = new OleDbConnection(validateDept.connetionString); OleDbDataAdapter AdapterCustomers = new OleDbDataAdapter( "SELECT EmployeeId, FirstName FROM Employee", connection); OleDbDataAdapter AdapterInvoices = new OleDbDataAdapter( "SELECT InvoiceId, InvoiceNumber, InvoiceDate, SalesPerson AS EmployeeId, Customername AS CustomerId, (Select CustomerName from Customer where Customer.CustomerId = NewInvoice_1.CustomerName) AS Customer_Name, DueDate, Tax, GrandTotal, CompanyId, InvoiceStatus FROM NewInvoice_1", connection); DataSet dataSet11 = new DataSet(); //Create DataTable objects for representing database's tables AdapterCustomers.Fill(dataSet11, "Employee"); AdapterInvoices.Fill(dataSet11, "Invoices"); //Set up a master-detail relationship between the DataTables DataColumn keyColumn = dataSet11.Tables["Employee"].Columns["EmployeeId"]; DataColumn foreignKeyColumn = dataSet11.Tables["Invoices"].Columns["EmployeeId"]; dataSet11.Relations.Add("CustomerInvoice", keyColumn, foreignKeyColumn); // Getting error on this row //Bind the grid control to the data source gridControl1.DataSource = dataSet11.Tables["Employee"]; gridControl1.ForceInitialize(); //Assign a CardView to the relationship GridView cardView1 = new GridView(gridControl1); gridControl1.LevelTree.Nodes.Add("CustomerInvoice", cardView1); //Specify text to be displayed within detail tabs. cardView1.ViewCaption = "Invoice List of a Customer"; //Create columns for the detail pattern View cardView1.PopulateColumns(dataSet11.Tables["Invoices"]);Thnakyou, Srihari
Thnakyou, Srihari
推荐答案
更多推荐
无法启用此约束,因为并非所有值都在c#中具有相应的父值?
发布评论