Click here to Skip to main content
13,247,740 members (61,416 online)
Rate this:
Please Sign up or sign in to vote.
See more:
I have 4 textbox on my window page and one button(Add) and a gridview now when i click on Add the data of four textbox should show in the grid view for that what i do on button click event of Add.

Plz,Plz , Anyone Can Help me
Posted 3-Dec-12 6:29am

1 solution

Rate this: bad
Please Sign up or sign in to vote.

Solution 1

I think you mean something like this ...
dataGridView1.Rows.Add(textBox1.Text, textBox2.Text, textBox3.Text, textBox4.Text);

This assumes that the Columns collection of the dataGridView was set up at design time

I've also seen your other question that said there were 8 text boxes... the better route would be to do something like this ...

DataTable dt = new DataTable("myTable");
dt.Columns.Add("column1", typeof(string));
dt.Columns.Add("column2", typeof(string));
dt.Columns.Add("column3", typeof(string));
dt.Columns.Add("column4", typeof(string));
dt.Rows.Add(textBox1.Text, textBox2.Text, textBox3.Text, textBox4.Text);
dataGridView1.DataSource = dt;
where the Columns collection of the dataGridView is empty at design time.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy |
Web03 | 2.8.171114.1 | Last Updated 3 Dec 2012
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100