How to Edit rows in DataGridView?

Posted by DanSogaard on Stack Overflow See other posts from Stack Overflow or by DanSogaard
Published on 2010-03-08T05:43:04Z Indexed on 2010/03/08 5:51 UTC
Read the original article Hit count: 749

Filed under:
|

So I've a button on my frmMain that opens up another frmEdit which has a datagridview that displays the following query:

BindingSource bs = new BindingSource();
string sqlqry = "select p_Name from Items where p_Id=" + p_Id;

SqlCeCommand cmd = new SqlCeCommand(sqlqry1, conn);
SqlCeDataReader rdr = cmd.ExecuteReader();
bs.DataSource = rdr;
dataGridView1.DataSource = bs;
this.ShowDialog(parent);

Now when frmEdit loads up the dgv displays the query just fine, but I can't Edit. I tried dgv.BeginEdit(true), but it doesn't work. The EditMode works fine if I used wizard to bind datasources to the dgv, but I need to execute my own customized queries and be able to update them directly.

© Stack Overflow or respective owner

Related posts about datagridview

Related posts about c#