How to use checkbox for 2 queries for population from DataGridView in vb.net?.
I tried with the code below the population in the datagridview became empty please recommend because maybe my code implementation has something wrong.
tHANKS
Private Sub PopulateDataGridView()
Try
dt = New DataTable
If CheckBox1.Checked = False Then
Dim query = "select ITM,ITC,QOH,PRS,PRSOBBRT,PRSOBNET,SHI,FILENAME1,FILENAME2,FILENAME3,FILENAME4,FILENAME5,FILENAME6,SUBFOLDERP FROM IFG WHERE QOH > 0 AND GDN = 'A.04.01.002.001'"
Else
If CheckBox1.Checked = True Then
Dim query = "select ITM,ITC,QOH,PRS,PRSOBBRT,PRSOBNET,SHI,FILENAME1,FILENAME2,FILENAME3,FILENAME4,FILENAME5,FILENAME6,SUBFOLDERP FROM IFG WHERE QOH < 0 AND GDN = 'A.04.01.002.001'"
Using adapter As New OleDbDataAdapter(query, cn.ToString)
adapter.Fill(dt)
End Using
Me.GridControl1.DataSource = dt
Me.GridControl1.Refresh()
GridView1.Columns("SUBFOLDERP").Visible = False
GridView1.Columns("FILENAME1").Visible = False
GridView1.Columns("FILENAME2").Visible = False
GridView1.Columns("FILENAME3").Visible = False
GridView1.Columns("FILENAME4").Visible = False
GridView1.Columns("FILENAME5").Visible = False
GridView1.Columns("FILENAME6").Visible = False
End If
End If
Catch myerror As OleDbException
MessageBox.Show("Error: " & myerror.Message)
Finally
End Try
End Sub
Aucun commentaire:
Enregistrer un commentaire