The following method is used by me to transfer data from 3 text boxes(as a single row) to a data grid view(dataGridView2) when a button is clicked:
private void button1_Click(object sender, EventArgs e)
{
Form1 f1 = new Form1();
DataTable dt1 = new DataTable();
f1.dataGridView2.DataSource = dt1;
dt1.Columns.Add("MessageID", typeof(string));
dt1.Columns.Add("Name", typeof(string));
dt1.Columns.Add("Number", typeof(string));
DataRow dr = dt1.NewRow();
dr["MessageID"] = IDtext.Text;
dr["Name"] = nameText.Text;
dr["Number"] = numberText.Text;
f1.dataGridView2.DataSource = dt1;
}
But when I click the button, neither an error occurs, and also no data is transferred to the relevant data grid. How can I correct this?
formand why you are settingGridViewDataSourcemultiple times?