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

Recommended Answers

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 …
Jump to Post

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

Jump to Post

All 10 Replies

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

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

really sory.... my mistake:)

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 ?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.