19/6/2014 Insert, Update, Delete with DataGridView Control in C# (Windows Application) | huizhaocode http://huizhaocode.wordpress.com/2012/07/06/insert-update-delete-with-datagridview-control-in-c-windows-application/comment-page-1/ 1/4 HUIZHAOCODE Insert, Update, Delete with DataGridView Control in C# (Windows Application) DataGridView control is one of the coolest features of Dot Net Framework. You can use this control in Windows Form using Wizard or programmatically. Add a DataGridView control and two Buttons on a Form. One Button is for deleting the selected row and other one is for updating or inserting new row. Declare those variables as shown below. In the Form Load event set data source for the DataGridView control. 1 2 3 4 5 6 7 8 9 10 11 12 13 14 public partial class DataTrialForm : Form { private String connectionString = null ; private SqlConnection sqlConnection = null ; private SqlDataAdapter sqlDataAdapter = null ; private SqlCommandBuilder sqlCommandBuilder = null ; private DataTable dataTable = null ; private BindingSource bindingSource = null ; private String selectQueryString = null ; public DataTrialForm() { InitializeComponent(); } 1 2 3 4 private void DataTraiForm_Load(object sender, EventArgs e) { connectionString = ConfigurationManager.AppSettings["connectionString"]; sqlConnection = new SqlConnection(connectionString);
4
Embed
Insert, Update, Delete With DataGridView Control in C#
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
19/6/2014 Insert, Update, Delete with DataGridView Control in C# (Windows Application) | huizhaocode
Insert, Update, Delete with DataGridView Control in C#
(Windows Application)
DataGridView control is one of the coolest features of Dot Net Framework. You can use this control in Windows Form using Wizard orprogrammatically.Add a DataGridView control and two Buttons on a Form. One Button is for deleting the selected row and other one is for updating or insertingnew row.
Declare those variables as shown below.
In the Form Load event set data source for the DataGridView control.