Click here to Skip to main content
15,886,110 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I am looking to output the data in my gridview to textboxs. I have multiple rows an cells in my gridview.

I have code that uses a button which outputs Data to a textbox. I want the data in the first column in textbox1 and next column in textbox2.

The code I wrote outputs the first row accross in Textbox1, the 1st & 2nd in Textbox2, the 1st & 2nd & 3rd in Textbox3 etc...

The problem I have with it is I want column 1 (going down) in textbox1 column 2 in textbox2 etc. Any help is greatly appreciated


any help on this would be great

What I have tried:

looping through rows and columns
Posted
Updated 24-Apr-19 23:30pm
v5

Just a guess:

For k As Integer = 0 To dv.Count - 1
  strTemp &= dv(k)("TxtDat").ToString.PadRight(50, " ") & vbCrLf
Next


strTemp = dv(i)("TxtDat").ToString.PadRight(50, " ") & vbCrLf
 
Share this answer
 
Comments
Member 14315477 23-Apr-19 4:03am    
I want to loop through so need the for statement I think....If I take it out I only get line one of what im looking not all the information.
Also guessing here...

I would;
1) Get the datagridview datasource (preferably as a DataTable)
2) Iterate columns or rows.

VB
Dim dataTable As DataTable = TryCast(dgv.DataSource, DataTable)

For Each column As DataColumn In dataTable.Columns
    For Each dRow as DataRow in dataTable.Rows
       TextBox1.Text = dRow[column]
    Exit
Exit


You will have to do a lot more debugging, but this is the jist of it IMO.
 
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