Solved

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

Posted on 2009-04-02
9
631 Views
Last Modified: 2012-08-14
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

0
Comment
Question by:PAMHART
  • 5
  • 4
9 Comments
 
LVL 83

Expert Comment

by:CodeCruiser
ID: 24058527
When do you want to validate? At what event? Would it be selected row only or for the whole data grid?
0
 

Author Comment

by:PAMHART
ID: 24059877
row only
0
 
LVL 83

Expert Comment

by:CodeCruiser
ID: 24059936
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
0
 

Author Comment

by:PAMHART
ID: 24077205
error with selectrows not part of system window form datagrid1
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 83

Expert Comment

by:CodeCruiser
ID: 24077542
Are you using DataGridView?
0
 

Author Comment

by:PAMHART
ID: 24077659
no, i am using vb.net 2003 with just a datagrid on a window form.
0
 
LVL 83

Accepted Solution

by:
CodeCruiser earned 500 total points
ID: 24077706
Try this then

if grid1.CurrentRowIndex >= 0 Then
   DSBC1.tables(0).defaultview.rowfilter = "ClientID=" & grid1.Item(Grid1.CurrentRowIndex, 0)
   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
0
 

Author Closing Comment

by:PAMHART
ID: 31565980
Thanks for the help.
0
 
LVL 83

Expert Comment

by:CodeCruiser
ID: 24077959
My Pleasure.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article explains how to create and use a custom WaterMark textbox class.  The custom WaterMark textbox class allows you to set the WaterMark Background Color and WaterMark text at design time.   IMAGE OF WATERMARKS STEPS Create VB …
Article by: jpaulino
XML Literals are a great way to handle XML files and the community doesn’t use it as much as it should.  An XML Literal is like a String (http://msdn.microsoft.com/en-us/library/system.string.aspx) Literal, only instead of starting and ending with w…
Internet Business Fax to Email Made Easy - With  eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, f…
As a trusted technology advisor to your customers you are likely getting the daily question of, ‘should I put this in the cloud?’ As customer demands for cloud services increases, companies will see a shift from traditional buying patterns to new…

895 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now