0

I have an application that displays the data of a sql database in a dataGridView via a dataSet. I was wondering if there was a way of updating the database by modifying the gridViewDirectly, like passing the data from the database to the grid, but inverted, instead of creating a new form that displays the editable info in textboxes and then the user changes what he has to change and clicks update. Is this possible?

2
  • you want to edit datagridview values in their cells in dgv?
    – Arash
    Commented Dec 2, 2012 at 21:03
  • Yes, that's what I want to do. Commented Dec 2, 2012 at 21:05

2 Answers 2

1

the DataGridView had a already feature to DataSet with BindingSource, TableAdapter and BindingNavigator Control by manipulating the data from database to DataGridView just drag and drop to your Form no more codes.

  1. Create a DataSet
  2. Drag Table to DataSet
  3. Go to "Data Sources" panel
  4. Drag the Table to your Form.
    And thats it! as you can see the "Save" and "Delete" button from BindingNavigator this will be your function to save, update and delete the data from your database using the DataGridView with DataSet

i apologize for my short tutorial and not very clear :)

0

you can put a button column in datagridview and when you press the button you can begin to edit dgv cells.

info: how can i add two buttons to a single datagrid column dynamically?

http://msdn.microsoft.com/en-us/library/system.windows.forms.datagridviewbuttoncolumn.aspx

Define DataGridView Column type Programmatically

If you need any other information about that please feel free to say

Edit:

You can do like this :

 DataGridViewButtonColumn clbt_delet = new DataGridViewButtonColumn();
   clbt_delete.HeaderText = "DELETE"
   clbt_delete.Text = "Delete";
   clbt_delete.UseColumnTextForButtonValue = true;
   dataGridView1.Columns.Add(clbt_delete);
0

Not the answer you're looking for? Browse other questions tagged or ask your own question.