How to maintain more row values between two forms in .NET?

In this article I am going to explain about how to maintain more row values between two forms in the windows application using data table.

Description :

In many cases we need to maintain more gridview row values and get back in the second form. You can store values in the datatable and get back in the second consider below example I have get values from form1 and display in the form2 control

Form Design


Code Behind

using System.Data;
namespace MaintainMoreValue
public partial class Form1 : Form
DataTable dt = new DataTable();
DataRow dr;
public Form1()
//In Load event create new datatable columns
private void Form1_Load(object sender, EventArgs e)

//add each record in data table when press submit
private void button1_Click(object sender, EventArgs e)
dr = dt.NewRow();
dr["id"] = textBox1.Text;
dr["name"] = textBox2.Text;
dr["addr"] = textBox3.Text;
dataGridView1.DataSource = dt;

//move to ouput form
private void button2_Click(object sender, EventArgs e)
//assign input form records to output form datatable
Form2.dt = dt;
Form2 obj = new Form2();



Source code:

Design: Form Design
Code Behind: C#


I hope this article is help you to know about how to get back more row values from form1 to form2.


  • MaintainMoreValue (44350-64848-MaintainMoreValue.rar)
  • Comments

    No responses found. Be the first to comment...

  • Do not include your name, "with regards" etc in the comment. Write detailed comment, relevant to the topic.
  • No HTML formatting and links to other web sites are allowed.
  • This is a strictly moderated site. Absolutely no spam allowed.
  • Name: