1

我有一个数据网格视图,我在其中设置了这样的值

string query = "select CustomerId,CustomerName from tbl_Customer where flag=0";
SqlDataAdapter daCustomer = new SqlDataAdapter(query, con);

daCustomer.Fill(ds, "Customer");

cmbCustomerName.DisplayMember = "CustomerName";
cmbCustomerName.ValueMember = "CustomerId";
cmbCustomerName.DataSource = ds.Tables["Customer"];
cmbCustomerName.ResetText();

但它在这一行之后给了我这个错误

 cmbCustomerName.DataSource = ds.Tables["Customer"];

当我设置数据源时。请帮我解决这个问题。

4

1 回答 1

0

尝试这个 :

    DataTable dt = new DataTable();
daCustomer.Fill(dt);
cmbCustomerName.DataSource = dt;
于 2012-06-20T08:50:15.437 回答