Find a Row that is not the primary key

Posted on 2005-04-18
Last Modified: 2012-05-05
(I'm using .NET compact framework 1.0 and VB.NET)

I have a datagrid that is bound to a datatable object called dtSR.  I want to find a row in a datatable that is not the primary key and put the datagrid on that row.

I have tried the select method of the datatable, which works:

Dim drFind() As DataRow = dtSR.Select("strStructureNo = '" & Me.txtFind.Text & "'")

But, I need to move my datatable, dtSR and my datagrid to this row.

Question by:gerrystrat
    LVL 23

    Accepted Solution

    use a DataView

    Dim dv As New DataView(dtSR,"strStructureNo = '" & Me.txtFind.Text & "'",string.Empty,DataViewRowState.CurrentRows)

    DataGrid.DataSource = dv


    Author Comment

    Thanks,  I ended up doing it this way so as not to lose the other rows in the datagrid.  

        Dim drFind() As DataRow = dtSR.Select("strStructureNo = '" & Me.txtFind.Text & "'")
        Dim iLocal As Integer = dvSR.Find(drFind(0).Item("intSequence"))
        If iLocal >= 0 Then
            Me.dgdLookup.CurrentRowIndex = iLocal

    I think I'm getting use to dot net...

    Featured Post

    How your wiki can always stay up-to-date

    Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
    - Increase transparency
    - Onboard new hires faster
    - Access from mobile/offline

    Join & Write a Comment

    Flash ( has evolved over the years to where it has become a masterful tool for displaying content screen.  It has excellent layout placement, UI precision as well as rendering capabilities. This, along with t…
    Many of us here at EE write code. Many of us write exceptional code; just as many of us write exception-prone code. As we all should know, exceptions are a mechanism for handling errors which are typically out of our control. From database errors, t…
    In this sixth video of the Xpdf series, we discuss and demonstrate the PDFtoPNG utility, which converts a multi-page PDF file to separate color, grayscale, or monochrome PNG files, creating one PNG file for each page in the PDF. It does this via a c…
    Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

    731 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

    15 Experts available now in Live!

    Get 1:1 Help Now