'Pass value from textbox to row in Grdicontrol in DevExpress

Im using Gridcontrol and i want to add products to gidview and i use this code

Public Sub InsertBarcode()
        Dim x As Integer
        Try
            If Con.State = 1 Then Close()
            Con.Open()
            Dim cmd As New SqlCommand("Select * from Products where ProdBarCode=@ProdBarCode", Con)
            cmd.Parameters.Clear()
            cmd.Parameters.AddWithValue("@ProdBarCode", SqlDbType.NVarChar).Value = TxtBarcode.Text
            Dim adp As New SqlDataAdapter(cmd)
            Dim dr As SqlDataReader
            dr = cmd.ExecuteReader
            If dr.HasRows Then
                While dr.Read
                    GridView1.AddNewRow()
                    x = GridView1.RowCount - 1

                    GridView1.SetRowCellValue(x, GridView1.Columns(0), dr("ProdId").ToString)
                    GridView1.SetRowCellValue(x, GridView1.Columns(1), dr("ProdName").ToString)
                    GridView1.SetRowCellValue(x, GridView1.Columns(2), dr("QtyAvailabe").ToString)
                    GridView1.SetRowCellValue(x, GridView1.Columns(3), dr("BuyPrice").ToString)
                    GridView1.UpdateCurrentRow()
                End While
                dr.Close()
                Con.Close()
            Else
                MsgBox("There is no data")
            End If


        Catch ex As Exception
            Con.Close()
        End Try
    End Sub

and this to call the method

Private Sub TxtBarcode_PreviewKeyDown(sender As Object, e As PreviewKeyDownEventArgs) Handles TxtBarcode.PreviewKeyDown
    If e.KeyCode = Keys.Enter Then
        InsertBarcode()
        TxtBarcode.Text = ""
    End If
End Sub

but when i add barcode there no data added to Row of gridview



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source