Bind data and auto show value in dropdown combobox.
I insert value in database and fetch value and show in datagrid view.
It shows but datagridview combobox value not show.
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Bikesh SrivastavaPosted Mar 22, 2017, 2:00 PM
manoj kumarPosted Mar 22, 2017, 7:37 AM
Jitendra YadavPosted Mar 22, 2017, 7:34 AM
manoj kumarPosted Mar 22, 2017, 12:18 AM
manoj kumarPosted Mar 21, 2017, 9:30 AM
Dim q As String
q = dgvDetails.CurrentRow.Index
txtHregd.Text = dgvDetails.Rows(Convert.ToInt32(q)).Cells(0).Value.ToString
txtSeriesNo.Text = dgvDetails.Rows(Convert.ToInt32(q)).Cells(1).Value.ToString
dtpBillDate.Text = dgvDetails.Rows(Convert.ToInt32(q)).Cells(2).Value.ToString
cbSeries.Text = dgvDetails.Rows(Convert.ToInt32(q)).Cells(3).Value.ToString
txtTotal.Text = dgvDetails.Rows(Convert.ToInt32(q)).Cells(4).Value.ToString
txtRmks.Text = dgvDetails.Rows(Convert.ToInt32(q)).Cells(5).Value.ToString
dgvMaster.Rows.Clear()
OraDap = New OracleDataAdapter("SELECT SL_NO,FARMER_NAME,ITEM_DESC,WT_QNTY,RATE,CUSTOMER_NAME,GATE_PASS_NO FROM EGMSDBA.H_REGISTER_DETAIL WHERE HSL_NO='" + txtHregd.Text + "'", Oracon)
dt2 = New DataTable
OraDap.Fill(dt2)
If dt2.Rows.Count > 0 Then
'dgvMaster.DataSource = dt2
' Dim CBCell As DataGridViewComboBoxCell = DirectCast(dgvMaster.Rows(Convert.ToInt32(S)).Cells(2), DataGridViewComboBoxCell)
'Dim CBCell As New DataGridViewComboBoxCell
If dt2.Rows.Count = 1 Then
dgvMaster.Rows(0).Cells(0).Value = dt2.Rows(0)("SL_NO").ToString
dgvMaster.Rows(0).Cells(1).Value = dt2.Rows(0)("FARMER_NAME").ToString
dgvMaster.Rows(0).Cells(2).Value = dt2.Rows(0)("ITEM_DESC").ToString
dgvMaster.Rows(0).Cells(3).Value = dt2.Rows(0)("WT_QNTY").ToString
dgvMaster.Rows(0).Cells(4).Value = dt2.Rows(0)("RATE").ToString
dgvMaster.Rows(0).Cells(5).Value = dt2.Rows(0)("CUSTOMER_NAME").ToString
dgvMaster.Rows(0).Cells(6).Value = dt2.Rows(0)("GATE_PASS_NO").ToString
Else
dgvMaster.Rows.Add(dt2.Rows.Count - 1)
For i As Integer = 0 To dt2.Rows.Count - 1
dgvMaster.Rows(i).Cells(0).Value = dt2.Rows(i)("SL_NO").ToString
dgvMaster.Rows(i).Cells(1).Value = dt2.Rows(i)("FARMER_NAME").ToString
dgvMaster.Rows(i).Cells(2).Value = dt2.Rows(i)("ITEM_DESC").ToString
' CType(dgvMaster.Rows(i).Cells(2), DataGridViewComboBoxCell).Value = CBCell.Value
dgvMaster.Rows(i).Cells(3).Value = dt2.Rows(i)("WT_QNTY").ToString
dgvMaster.Rows(i).Cells(4).Value = dt2.Rows(i)("RATE").ToString
dgvMaster.Rows(i).Cells(5).Value = dt2.Rows(i)("CUSTOMER_NAME").ToString
dgvMaster.Rows(i).Cells(6).Value = dt2.Rows(i)("GATE_PASS_NO").ToString
Next
End If
End If
End Sub
Ramesh PalanivelPosted Mar 21, 2017, 9:01 AM