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
When do you want to validate? At what event? Would it be selected row only or for the whole data grid?
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).defaultvie w.rowfilte r = "ClientID=" & grid1.SelectedRows(0).Cell s(0).Value
if DSBC1.Tables(0).DefaultVie w.Count > 0 then
'The ClientID exists
Else
'The ClientID does not exist
End if
DSBC1.Tables(0).DefaultVie w.RowFilte r = ""
End If
btnValidate.Press:
if grid1.Selectedrows.count = 1 Then
DSBC1.tables(0).defaultvie
if DSBC1.Tables(0).DefaultVie
'The ClientID exists
Else
'The ClientID does not exist
End if
DSBC1.Tables(0).DefaultVie
End If
ASKER
error with selectrows not part of system window form datagrid1
Are you using DataGridView?
ASKER
no, i am using vb.net 2003 with just a datagrid on a window form.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks for the help.
My Pleasure.