1,105,409 Community Members

insert text from textbox to a DataGridView

Member Avatar
de Source
Junior Poster in Training
66 posts since Aug 2010
Reputation Points: 0 [?]
Q&As Helped to Solve: 3 [?]
Skill Endorsements: 0 [?]
 
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..

Member Avatar
ddanbe
Posting Expert
5,354 posts since Oct 2008
Reputation Points: 2,066 [?]
Q&As Helped to Solve: 908 [?]
Skill Endorsements: 46 [?]
Featured
 
0
 
Member Avatar
Mitja Bonca
Posting Maven
2,561 posts since May 2009
Reputation Points: 557 [?]
Q&As Helped to Solve: 489 [?]
Skill Endorsements: 21 [?]
 
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;
Member Avatar
de Source
Junior Poster in Training
66 posts since Aug 2010
Reputation Points: 0 [?]
Q&As Helped to Solve: 3 [?]
Skill Endorsements: 0 [?]
 
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

Member Avatar
Mitja Bonca
Posting Maven
2,561 posts since May 2009
Reputation Points: 557 [?]
Q&As Helped to Solve: 489 [?]
Skill Endorsements: 21 [?]
 
1
 

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

Member Avatar
de Source
Junior Poster in Training
66 posts since Aug 2010
Reputation Points: 0 [?]
Q&As Helped to Solve: 3 [?]
Skill Endorsements: 0 [?]
 
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

Member Avatar
ddanbe
Posting Expert
5,354 posts since Oct 2008
Reputation Points: 2,066 [?]
Q&As Helped to Solve: 908 [?]
Skill Endorsements: 46 [?]
Featured
 
0
 

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

Member Avatar
de Source
Junior Poster in Training
66 posts since Aug 2010
Reputation Points: 0 [?]
Q&As Helped to Solve: 3 [?]
Skill Endorsements: 0 [?]
 
0
 

really sory.... my mistake:)

Question Answered as of 2 Years Ago by ddanbe and Mitja Bonca
Member Avatar
ddanbe
Posting Expert
5,354 posts since Oct 2008
Reputation Points: 2,066 [?]
Q&As Helped to Solve: 908 [?]
Skill Endorsements: 46 [?]
Featured
 
0
 

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

Member Avatar
sameer.iqbal.716
Newbie Poster
1 post since Jul 2012
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
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

Member Avatar
cmdc08
Newbie Poster
1 post since Aug 2013
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
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