INSERT DATA IN DATAGRIDVIEW FROM TEXT BOX C#

Ankit Singh

Total Post:341

Points:2389
Posted by  Ankit Singh
C#
 950  View(s)
Ratings:
Rate this:
we want to insert data in datagridview from text box c#. how to do this please help me.
  1. aditya kumar Patel

    Post:254

    Points:1810
    Re: insert data in datagridview from text box c#

    here we are going to insert data in datagridview from text box dynamically using c# code windows application.
    we are provide demo code and design.

    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Linq;
    using System.Text;
    using System.Windows.Forms;

    namespace WindowsForums
    {
    public partial class FORUM : Form
    {
    public FORUM()
    {
    InitializeComponent();
    }
    DataTable dt = new DataTable();

    private void FORUM_Load(object sender, EventArgs e)
    {
    dt.Columns.Add("Name");
    dt.Columns.Add("Email");
    dataGridView1.DataSource = dt;
    dataGridView1.Columns[0].Width = 200;
    dataGridView1.Columns[1].Width = 300;

    }

    private void btnupdate_Click(object sender, EventArgs e)
    {

    DataRow dr = dt.NewRow();
    dt.Rows.Add(dr);
    dr[0] = txtname.Text;
    dr[1] = txtemail.Text;
    dataGridView1.DataSource = dt;

    }
    }
    }


  1. Todd Jenny

    Post:2

    Points:14
    Re: insert data in datagridview from text box c#

    Post is removed by the Admin.

Answer

NEWSLETTER

Enter your email address here always to be updated. We promise not to spam!