ตรงนี้เป็นค้นหาแล้วแสดงใน datagrid ผมอยากได้ ค่า index ของแถวแรกมันต้องทำอย่างไรครับ
Code (VB.NET)
Private Sub SearchButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SearchButton.Click
UseConnectDatabase()
Dim sql As String = "select * from alcohol where al_no like '%" & SearchTextBox.Text & "%' order by al_id asc"
Dim cmd As New MySqlCommand(sql, MyConnect)
adapter = New MySqlDataAdapter(cmd)
If Not (data.Tables("alcohol") Is Nothing) Then
data.Tables("alcohol").Clear()
End If
adapter.Fill(data, "alcohol")
AlcoholDataGridView.DataSource = data.Tables("alcohol")
End Sub
Dim USelectRow As Integer = 0
Dim PrepDate As String
Dim Store As String
If GrdHeader.SelectedRows.Count > 0 Then
IsFind = True 'กำหนด IsFind as Boolean ไว้บนสุด
End If
If IsFind = True Then
TxtGetSupplierPO.Text = ""
USelectRow = GrdHeader.CurrentRow.Index()
PrepDate = DDSet.Tables(0).Rows(USelectRow).Item(0).ToString
Store = DDSet.Tables(0).Rows(USelectRow).Item(1).ToString
End If