1.11M Members

insert text from textbox to a DataGridView

 
0
 

hi,
i am making a search button which searches a particular row from a database i've been all through this and able to get record in a text box or a message box

txtbox1.Text = dr1["First_Name"].ToString();
txtbox2.Text = dr1["Last_Name"].ToString();
txtbox3.Text = dr1["Job_Title"].ToString();

but i am stuck how to get that record in a datagridview rowwise
i dont have any experience with datagridview so kindly express your solution in bit detail

do help plz..

 
1
 

i dont have any experience with datagridview so kindly express your solution in bit detail

hmmm, this will take some time then... ;)

Ok, regarding to your thread`s title, you want to pass data from textBox to DGV. You can do it this (Simple) way:

dataGrivView1[0,0].Value = txtbox1.Text; //0,0 is 1st column, 1st row
dataGrivView1[1,0].Value = txtbox1.Text; //1,0 is 2nd column, 1st row
dataGrivView1[2,0].Value = txtbox1.Text; //2,0 is 3rd column, 1st row

//for example if you want to pass data to 5th column and 10 row you do:
dataGrivView1[9,4].Value = txtbox1.Text;
 
0
 

thanks to both of you
mitja you make it very simple to me although it was but i was unaware:P
but thnks again

 
1
 

You are welcome.
If this is was helpful upVote, or if this was it, mark the thread as answered, so we close it.

 
0
 

@ mitja

why i am having error


The name 'dataGrivView1' does not exist in the current context

although i have drop that datagridview in the same form

 
0
 

'dataGrivView1' is this a typo?
Should be dataGridView1 I guess.

 
0
 

really sory.... my mistake:)

Question Answered as of 3 Years Ago by ddanbe and Mitja Bonca
 
0
 

Don't feel sorry! If you would give me 1 dollar for all the typos I have made you would feel very poor :)

 
0
 

I have the error "Additional information: Index was out of range. Must be non-negative and less than the size of the collection" in passing data from texboxes to the datagrid ...!!

please help

 
0
 

The same thing i want to add data from text box to dataGridView but one line from textbox to 1st row of the datagridview and so on how can i do that ?

You
This question has already been solved: Start a new discussion instead
Post:
Start New Discussion
Tags Related to this Article