Wrox Home  
Search P2P Archive for: Go

  Return to Index  

ado_dotnet thread: RE: How to find a record in a datatable and move the pointer to this position


Message #1 by "Radoslaw Kociolek" <mcradie@p...> on Wed, 4 Dec 2002 08:17:59
> Bill,
First, to find the record(s) that match your criteria, construct a new
DataView with a Filter (this in effect contains the WHERE clause of a
SQL query).
When you know the PK of the record you want to move to, then you must
set the BindingContext.Position to the record number, which you can
obtain using the Find() method.

e.g.

  DataView dv = new DataView(dsWS.WorkSet,"","ObjectID",
DataViewRowState.CurrentRows);
  int newPos = dv.Find(objectID);	// objectID is the PK in this
case
  if (newPos >= 0)	// found it
 	this.BindingContext[dsWS,"WorkSet"].Position = newPos;

brian

-----Original Message-----
From: Shankar s/o Poobalagan [mailto:pshark@p...] 
Sent: Wed, 30 Oct 2002 16:15
To: ADO.NET
Subject: [ado_dotnet] How to find a record in a datatable and move the
pointer to this position


I have a data entry form with a VCR option. In this form I also have a
FIND button to find records by the Primary Key. After I obtain the key
to search, how do I find these record in a 
data table and how do I move the pointer to this found record ?

Thanks & Regards,
Bill

---
ASP.NET Distributed Data Applications
This book will inspire you with a range of ideas on how data 
can be used to drive Web applications, and how that data can 
be most effectively utilized at each level of the design. 
Inefficient data use leads to the sort of slow, unresponsive 
Web applications that nobody enjoys using. By making good use 
of both server and client-side code, we can solve these 
problems. This book will arm you with the techniques you need 
to build Web applications that fly.
http://www.wrox.com/ACON11.asp?ISBN=1861004923

Message #2 by "Radoslaw Kociolek" <mcradie@p...> on Wed, 4 Dec 2002 08:26:37
Is where any way to do it when sorting is on another column (not a PK)?

Thanks in advance
McRadie

> Bill,
First, to find the record(s) that match your criteria, construct a new
DataView with a Filter (this in effect contains the WHERE clause of a
SQL query).
When you know the PK of the record you want to move to, then you must
set the BindingContext.Position to the record number, which you can
obtain using the Find() method.

e.g.

  DataView dv = new DataView(dsWS.WorkSet,"","ObjectID",
DataViewRowState.CurrentRows);
  int newPos = dv.Find(objectID);	// objectID is the PK in this
case
  if (newPos >= 0)	// found it
 	this.BindingContext[dsWS,"WorkSet"].Position = newPos;

brian
Message #3 by "Shaneil Narayan" <SNarayan@e...> on Mon, 9 Dec 2002 11:40:37 +1200
How do I move the pointer to the the required record? I have the following
code in the Click event of a Search button.

The code below fills the datagrid with the matching SampleNo. only.
----------------------------------------------------------------------------
---------
Dim sSearch As String

        sSearch = UCase(InputBox("Enter Sample Number to search.",
"Search"))

        'Create a new dataView and filter
        Dim dvView As New DataView()
        With dvView
            .Table = DsEditFSamp1.Tables("FaceSample")
            .AllowEdit = True
            .AllowDelete = True
            .Sort = "SAMPLENO"
            .RowFilter = "SampleNo like '%" & sSearch & "%'"
        End With

        DataGrid1.DataSource = dvView

----------------------------------------------------------------------------
-------

Thanks in advance.

Message #4 by "Brian Smith" <bsmith@l...> on Mon, 9 Dec 2002 09:54:01 -0000
What pointer?

brian

-----Original Message-----
From: Shaneil Narayan [mailto:SNarayan@e...] 
Sent: Sun, 08 Dec 2002 23:41
To: ADO.NET
Subject: [ado_dotnet] RE: How to find a record in a datatable and move
the pointer to this position
Importance: High


How do I move the pointer to the the required record? I have the
following code in the Click event of a Search button.

The code below fills the datagrid with the matching SampleNo. only.
------------------------------------------------------------------------
----
---------
Dim sSearch As String

        sSearch = UCase(InputBox("Enter Sample Number to search.",
"Search"))

        'Create a new dataView and filter
        Dim dvView As New DataView()
        With dvView
            .Table = DsEditFSamp1.Tables("FaceSample")
            .AllowEdit = True
            .AllowDelete = True
            .Sort = "SAMPLENO"
            .RowFilter = "SampleNo like '%" & sSearch & "%'"
        End With

        DataGrid1.DataSource = dvView

------------------------------------------------------------------------
----
-------

Thanks in advance.


===
Fast Track ADO.NET with C# is a concise introduction to the concepts,
techniques, and libraries that you will need in order to start using
ADO.NET in your applications. The book covers DataSets and Typed
DataSets, accessing data using DataReaders and DataAdaptors, the close
relationship between ADO.NET and XML, how and where to use ADO.NET in
your enterprise applications, and how to use Web Services and ADO.NET to
easily pass data between applications.
http://www.wrox.com/books/1861007604.htm

---
Incoming mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.427 / Virus Database: 240 - Release Date: 06/12/2002
 

---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.427 / Virus Database: 240 - Release Date: 06/12/2002
 

Message #5 by "Mazen Alzogbi" <lists@a...> on Mon, 9 Dec 2002 14:11:35 +0400
Do you mean that you want to return the index of a certain row in a
DataView depending on a value searched inside the DataView?

If this is the case then check the DataView.Find method documentation @
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/h
tml/frlrfSystemDataDataViewClassFindTopic.asp

Regards,

Mazen Alzogbi [AspElite]
Editor and .NET Developer
ArabASP.NET - The #1 Arabic ASP.NET Community Site
www.arabasp.net

-----Original Message-----
From: Shaneil Narayan [mailto:SNarayan@e...] 
Sent: Monday, December 09, 2002 3:41 AM
To: ADO.NET
Subject: [ado_dotnet] RE: How to find a record in a datatable and move
the pointer to this position
Importance: High

How do I move the pointer to the the required record? I have the
following
code in the Click event of a Search button.

The code below fills the datagrid with the matching SampleNo. only.
------------------------------------------------------------------------
----
---------
Dim sSearch As String

        sSearch = UCase(InputBox("Enter Sample Number to search.",
"Search"))

        'Create a new dataView and filter
        Dim dvView As New DataView()
        With dvView
            .Table = DsEditFSamp1.Tables("FaceSample")
            .AllowEdit = True
            .AllowDelete = True
            .Sort = "SAMPLENO"
            .RowFilter = "SampleNo like '%" & sSearch & "%'"
        End With

        DataGrid1.DataSource = dvView

------------------------------------------------------------------------
----
-------

Thanks in advance.


===
Fast Track ADO.NET with C# is a concise introduction to the concepts,
techniques, and libraries that you will need in order to start using
ADO.NET in your applications. The book covers DataSets and Typed
DataSets, accessing data using DataReaders and DataAdaptors, the close
relationship between ADO.NET and XML, how and where to use ADO.NET in
your enterprise applications, and how to use Web Services and ADO.NET to
easily pass data between applications.
http://www.wrox.com/books/1861007604.htm

Message #6 by "Shaneil Narayan" <SNarayan@e...> on Tue, 10 Dec 2002 07:42:48 +1200
In a datagrid, there is a pointer (or arrow) on the left side indicating
which record is currently selected.

-----Original Message-----
From: Brian Smith [mailto:bsmith@l...]
Sent: Monday, 9 December 2002 9:54 PM
To: ADO.NET
Subject: [ado_dotnet] RE: How to find a record in a datatable and move
the pointer to this position


What pointer?

brian

-----Original Message-----
From: Shaneil Narayan [mailto:SNarayan@e...]
Sent: Sun, 08 Dec 2002 23:41
To: ADO.NET
Subject: [ado_dotnet] RE: How to find a record in a datatable and move
the pointer to this position
Importance: High


How do I move the pointer to the the required record? I have the
following code in the Click event of a Search button.

The code below fills the datagrid with the matching SampleNo. only.
------------------------------------------------------------------------
----
---------
Dim sSearch As String

        sSearch = UCase(InputBox("Enter Sample Number to search.",
"Search"))

        'Create a new dataView and filter
        Dim dvView As New DataView()
        With dvView
            .Table = DsEditFSamp1.Tables("FaceSample")
            .AllowEdit = True
            .AllowDelete = True
            .Sort = "SAMPLENO"
            .RowFilter = "SampleNo like '%" & sSearch & "%'"
        End With

        DataGrid1.DataSource = dvView

------------------------------------------------------------------------
----
-------

Thanks in advance.


===
Fast Track ADO.NET with C# is a concise introduction to the concepts,
techniques, and libraries that you will need in order to start using
ADO.NET in your applications. The book covers DataSets and Typed
DataSets, accessing data using DataReaders and DataAdaptors, the close
relationship between ADO.NET and XML, how and where to use ADO.NET in
your enterprise applications, and how to use Web Services and ADO.NET to
easily pass data between applications.
http://www.wrox.com/books/1861007604.htm

---
Incoming mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.427 / Virus Database: 240 - Release Date: 06/12/2002


---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.427 / Virus Database: 240 - Release Date: 06/12/2002



===
Fast Track ADO.NET with C# is a concise introduction to the concepts,
techniques, and libraries that you will need in order to start using ADO.NET
in your applications. The book covers DataSets and Typed DataSets, accessing
data using DataReaders and DataAdaptors, the close relationship between
ADO.NET and XML, how and where to use ADO.NET in your enterprise
applications, and how to use Web Services and ADO.NET to easily pass data
between applications.
http://www.wrox.com/books/1861007604.htm

Message #7 by "Brian Smith" <bsmith@l...> on Mon, 9 Dec 2002 22:52:42 -0000
You have to do it via the BindingContext:

E.g.
  this.BindingContext[dataSet,"tableName"].Position = newPosition;

Brian

-----Original Message-----
From: Shaneil Narayan [mailto:SNarayan@e...] 
Sent: Mon, 09 Dec 2002 19:43
To: ADO.NET
Subject: [ado_dotnet] RE: How to find a record in a datatable and move
the pointer to this position
Importance: High


In a datagrid, there is a pointer (or arrow) on the left side indicating
which record is currently selected.

-----Original Message-----
From: Brian Smith [mailto:bsmith@l...]
Sent: Monday, 9 December 2002 9:54 PM
To: ADO.NET
Subject: [ado_dotnet] RE: How to find a record in a datatable and move
the pointer to this position


What pointer?

brian

-----Original Message-----
From: Shaneil Narayan [mailto:SNarayan@e...]
Sent: Sun, 08 Dec 2002 23:41
To: ADO.NET
Subject: [ado_dotnet] RE: How to find a record in a datatable and move
the pointer to this position
Importance: High


How do I move the pointer to the the required record? I have the
following code in the Click event of a Search button.

The code below fills the datagrid with the matching SampleNo. only.
------------------------------------------------------------------------
----
---------
Dim sSearch As String

        sSearch = UCase(InputBox("Enter Sample Number to search.",
"Search"))

        'Create a new dataView and filter
        Dim dvView As New DataView()
        With dvView
            .Table = DsEditFSamp1.Tables("FaceSample")
            .AllowEdit = True
            .AllowDelete = True
            .Sort = "SAMPLENO"
            .RowFilter = "SampleNo like '%" & sSearch & "%'"
        End With

        DataGrid1.DataSource = dvView

------------------------------------------------------------------------
----
-------

Thanks in advance.


===
Fast Track ADO.NET with C# is a concise introduction to the concepts,
techniques, and libraries that you will need in order to start using
ADO.NET in your applications. The book covers DataSets and Typed
DataSets, accessing data using DataReaders and DataAdaptors, the close
relationship between ADO.NET and XML, how and where to use ADO.NET in
your enterprise applications, and how to use Web Services and ADO.NET to
easily pass data between applications.
http://www.wrox.com/books/1861007604.htm
---
Change your mail options at http://p2p.wrox.com/manager.asp or to
unsubscribe send a blank email to 

---
Incoming mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.427 / Virus Database: 240 - Release Date: 06/12/2002


---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.427 / Virus Database: 240 - Release Date: 06/12/2002



===
Fast Track ADO.NET with C# is a concise introduction to the concepts,
techniques, and libraries that you will need in order to start using
ADO.NET in your applications. The book covers DataSets and Typed
DataSets, accessing data using DataReaders and DataAdaptors, the close
relationship between ADO.NET and XML, how and where to use ADO.NET in
your enterprise applications, and how to use Web Services and ADO.NET to
easily pass data between applications.
http://www.wrox.com/books/1861007604.htm
---
Change your mail options at http://p2p.wrox.com/manager.asp or to
unsubscribe send a blank email to 


===
Fast Track ADO.NET with C# is a concise introduction to the concepts,
techniques, and libraries that you will need in order to start using
ADO.NET in your applications. The book covers DataSets and Typed
DataSets, accessing data using DataReaders and DataAdaptors, the close
relationship between ADO.NET and XML, how and where to use ADO.NET in
your enterprise applications, and how to use Web Services and ADO.NET to
easily pass data between applications.
http://www.wrox.com/books/1861007604.htm

---
Incoming mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.427 / Virus Database: 240 - Release Date: 06/12/2002
 

---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.427 / Virus Database: 240 - Release Date: 06/12/2002
 


  Return to Index