Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C#
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
good
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.
  Permalink  
v2

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



Advertise | Privacy | Mobile
Web04 | 2.8.150326.1 | Last Updated 3 Dec 2012
Copyright © CodeProject, 1999-2015
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