Click here to Skip to main content
15,888,984 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
how to get textbox value in gridview in window application
Posted

try like this
C#
dataGrivView1[0,0].Value = txtbox1.Text;

or
assign the textbox values to datarow like
C#
	DataRow rd;
rd[0]=txtbox1.text;
and declare a data table
datatable dt=new datatable;
dt.rows .add(rd);
dataGridView.Datasource=dt;


or
C#
DataGridViewRow row = new DataGridViewRow();
 	  
 	row.CreateCells(this.dataGridView1, textBox1.Text, textBox2.Text, textBox3.Text);
 	   
 	this.dataGridView1.Rows.Add(row);
 
Share this answer
 
v2
Refer to this similar CP Q&A (solution 6),

How to insert a value from text box to grid view[^]
 
Share this answer
 
Hi Periyasamy,
Try this-
C#
dataGridView1.CurrentRow.Cells["Column name"].Value = textBox1.Text;
 
Share this answer
 

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900