Data Insert in Table by Data Gridview Control.



DataGridView1.gif

DataGridView2.gif

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Data.SqlClient;
 
namespace WindowsApplication11
{
    public partial class Form1 : Form
    {
        SqlConnection con = new SqlConnection();
        DataTable dt;

        public Form1()
        {
            InitializeComponent();
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            // TODO: This line of code loads data into the 'tRAILDataSet.CAL_TABLE' table. You can move, or remove it, as needed.
            this.cAL_TABLETableAdapter.Fill(this.tRAILDataSet.CAL_TABLE);
 
        }

        private void btnAdd_Click(object sender, EventArgs e)
        {
            dt = tRAILDataSet.Tables["CAL_TABLE"];                
            cAL_TABLETableAdapter.Update(tRAILDataSet.CAL_TABLE);
           
        }

        private void btnExit_Click(object sender, EventArgs e)
        {
            con.Close();
            this.Close();
        }
    }
}

Ebook Download
View all
Learn
View all