• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 2177
  • Last Modified:

Find a Row that is not the primary key

(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.

Thanks
0
gerrystrat
Asked:
gerrystrat
1 Solution
 
b1xml2Commented:
use a DataView

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

DataGrid.DataSource = dv
DataGrid.DataBind()


0
 
gerrystratAuthor Commented:
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
    Else...


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

Featured Post

What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now