Posted by: Sourav | June 1, 2015

Load data on textbox when I click on the first row on datagridview solved,VB.Net


On the delete page I have gridview3

 Private Sub DataGridView3_CellClick(sender As Object, e As DataGridViewCellEventArgs) Handles DataGridView3.CellClick
        If e.RowIndex >= 0 Then
            Dim row As DataGridViewRow
            row = Me.DataGridView3.Rows(e.RowIndex)
            TextBox7.Text = RTrim((row.Cells(“Name”).Value.ToString))
        End If

    End Sub

    Private Sub DataGridView3_CellContentClick(sender As Object, e As DataGridViewCellEventArgs) Handles DataGridView3.CellContentClick
        If e.RowIndex > 0 Then
            Dim row As DataGridViewRow
            row = Me.DataGridView3.Rows(e.RowIndex)
            TextBox7.Text = (row.Cells(“Name”).Value.ToString)
        End If
    End Sub

Due to this code every time I click on gridview the name in the selected row of the gridview appears on the textbox

If I use e.RowIndex >0 when I click on the top row(not the ID,Name .. row,but the first row with valid data) the name was not appearing on the textbox

So I used

If e.RowIndex >= 0 Then

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Categories

%d bloggers like this: