“未找到列”

时间:2016-11-08 01:09:47

标签: c# datagrid

我正在尝试使用另一个数据集(AO表)中的行从数据集(sku表)中提取行。但我的代码断了,并说我运行程序时找不到“skuid”列。任何人都可以帮忙解决这个错误吗?

在Cs中我有:

private void dataGridView1_RowHeaderMouseClick(object sender,DataGridViewCellMouseEventArgs e)    
{
    using (BTGroupDBDataContext db = new BTGroupDBDataContext(Globals.connectionString))
    {
        var skufind =  ( from c in db.SKUs
                        where c.id == (int)dataGridView1.Rows[e.RowIndex].Cells["skuid"].Value
                        select c.id).SingleOrDefault();

        sKUTableAdapter.FillBy(this.bTGroupDBDataSet.SKU, (int)skufind);
    }
}

和datagrid 1的设计者我有:

this.dataGridView1.AutoGenerateColumns = false;    
this.dataGridView1.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
this.dataGridView1.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] {
this.idDataGridViewTextBoxColumn,
this.orderidDataGridViewTextBoxColumn,
this.dateDataGridViewTextBoxColumn,
this.skuDataGridViewTextBoxColumn,
this.priceDataGridViewTextBoxColumn,
this.skuidDataGridViewTextBoxColumn,
this.roiDataGridViewTextBoxColumn,
this.amazoncommissionDataGridViewTextBoxColumn,
this.fbafeeDataGridViewTextBoxColumn});
this.dataGridView1.DataSource = this.amazonOrderBindingSource;
this.dataGridView1.Location = new System.Drawing.Point(264, 52);
this.dataGridView1.Name = "dataGridView1";
this.dataGridView1.Size = new System.Drawing.Size(503, 245);
this.dataGridView1.TabIndex = 0;
this.dataGridView1.CellContentClick += new        System.Windows.Forms.DataGridViewCellEventHandler(this.dataGridView1_CellContentClick);
this.dataGridView1.RowHeaderMouseClick += new System.Windows.Forms.DataGridViewCellMouseEventHandler(this.dataGridView1_RowHeaderMouseClick);

0 个答案:

没有答案