Reputation: 1941
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?
Upvotes: 0
Views: 2434
Reputation: 3061
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);
Upvotes: 0
Reputation: 7092
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.
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 :)
Upvotes: 1