Start New Discussion within our Software Development Community

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..

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;

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

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

@ 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

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

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

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 ?

This question has already been answered. Start a new discussion instead.