Transferring data from datagrid to textboxes

angela1979

New member
Joined
Mar 2, 2006
Messages
3
Programming Experience
Beginner
I'm fairly new to VB.NET. I have data in the datagrid and was just wondering if one could select a record in the datagrid and send the fields into textboxes.
Thanks
 
If the datagrid is bound to a dataset then you could bind the textboxes to the fields of the same table and the datagrid and textboxes would stay in sync - when you change rows the textbox values change.

Or else you can use the cell changed event like this:

VB.NET:
    Private Sub DataGrid1_CurrentCellChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles DataGrid1.CurrentCellChanged
        If Not DataGrid1.Item(DataGrid1.CurrentCell) Is DBNull.Value Then
            TextBox1.Text = DataGrid1.Item(DataGrid1.CurrentCell)
        End If
    End Sub
 
Last edited:
What should I change from that code to make mine when I select a record it will put the values in the text boxes? I mean the columns. Do I add something?
 
We're develping a sql server 2000 based vb.net application. In this we are required to fetch the record set of a row selected from a data-grid. First the stored procedure is used to populate the datagrid, then we double click the particular record from the grid. The application requires to capture the primary key from the selected record from the grid, and display the details on another problem.......can anyone help us ???
 
Back
Top