Link to home
Start Free TrialLog in
Avatar of PAMHART
PAMHART

asked on

vb.net 2003 datagrid validate current cell against another dataset value

I have a datagrid that fills from a load button then  we will scan a barcode label in the first column of the datagrid i want it to validate that value against DSBC1 dataset to see if it is valid. how do i get the current cell value and validate that value.


here is my load code for the datagrid.
  Private Sub LoadBtn_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles LoadBtn.Click
        Me.SqlSelectCommand1.Parameters("@Cuttxt").Value = Me.CutIdtxt.Text
        Me.lblmarker.DataBindings.Clear()
        Me.lblmarker.DataBindings.Add(New System.Windows.Forms.Binding("Text", Me.CutDetailsDS1, "VwCutTicketDetails.Actual Marker"))
        Me.SqlSelectCommand2.Parameters("@Cuttxt").Value = Me.CutIdtxt.Text
        Me.ScrapDS1.ScrapTable.Columns("CutID").DefaultValue = Me.CutIdtxt.Text
        Me.SqlDataAdapter1.Fill(Me.ScrapDS1)
       
 
        Me.SqlDataAdapter2.Fill(Me.CutDetailsDS1)
        Me.ScrapDS1.ScrapTable.Columns("Item").DefaultValue = Me.lblfab.Text
        Me.lblfab.ForeColor = System.Drawing.Color.Red
        If Me.lblmarker.Text = Me.ToString.Empty Then
            Me.lblmarker.DataBindings.Clear()
            Me.lblmarker.DataBindings.Add(New System.Windows.Forms.Binding("Text", Me.CutDetailsDS1, "VwCutTicketDetails.Marker"))
        End If
 
        Me.DataGrid1.Focus()
 
    End Sub

Open in new window

Avatar of Nasir Razzaq
Nasir Razzaq
Flag of United Kingdom of Great Britain and Northern Ireland image

When do you want to validate? At what event? Would it be selected row only or for the whole data grid?
Avatar of PAMHART
PAMHART

ASKER

row only
I do not understand your code fully but here is an example. I hope you can modify it according to your requirements.

btnValidate.Press:

if grid1.Selectedrows.count = 1 Then
   DSBC1.tables(0).defaultview.rowfilter = "ClientID=" & grid1.SelectedRows(0).Cells(0).Value
   if DSBC1.Tables(0).DefaultView.Count > 0 then
      'The ClientID exists
   Else
      'The ClientID does not exist
   End if
   DSBC1.Tables(0).DefaultView.RowFilter = ""
End If
Avatar of PAMHART

ASKER

error with selectrows not part of system window form datagrid1
Are you using DataGridView?
Avatar of PAMHART

ASKER

no, i am using vb.net 2003 with just a datagrid on a window form.
ASKER CERTIFIED SOLUTION
Avatar of Nasir Razzaq
Nasir Razzaq
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of PAMHART

ASKER

Thanks for the help.
My Pleasure.