错误 - 失败,因为绑定文本框时无法创建子列表

时间:2014-04-02 17:24:29

标签: c# winforms data-binding

我无法将文本框绑定到数据集。它说save1(mytablename)无法创建子列表。这是代码;基本上问题出在我放置********

的文本框中
DataSet myDataset = new DataSet("saving1");
DataSet myDataset2 = new DataSet();
myDataAdapter.Fill(myDataset, "saving1");
myDataAdapter2.Fill(myDataset2, "extrasave");


dataGridView1.DataSource = myDataset.Tables["saving1"];
dataGridView3.DataSource = myDataset2.Tables["extrasave"];
myDataset2.Merge(myDataset);


dataGridView2.DataSource = myDataset.Tables["saving1"];
// Use the DataMember property to specify the DataTable.
dataGridView2.DataMember = "saving1";
//dataGridView1.SetDataBinding(ds, "saving1");
//comboBox2.DataSource = ds;
// comboBox2.DisplayMember = "items";
//comboBox2.ValueMember = "items";
comboBox2.DataSource = myDataset.Tables["saving1"];
comboBox2.DisplayMember = "items";
comboBox2.ValueMember = "ID";

quantitys.DataBindings.Add("Text", myDataset, "saving1.quantity");*********
receipts.DataBindings.Add("Text", myDataset, "saving1.receipt");***********
cashs.DataBindings.Add("Text", myDataset, "saving1.cash");**********
cheques.DataBindings.Add("Text", myDataset, "saving1.cheque");********

1 个答案:

答案 0 :(得分:0)

尝试评论该行:

// dataGridView2.DataMember = "saving1";

行,因为您已经将DataSource设置为DataSet中的特定DataTable