473,698 Members | 2,376 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Retrieving index for a particular row from dataset

Hello All,

Was wondering if we could retrieve the index of a particular row from a
dataset's table based on the filter criteria for the row?

For example, I have 4 rows in my datatable which is inside a dataset. One of
the columns is "ID" field. If I want to retrieve the row index of a row with
ID = 10, is there any API which I could use in .NET framework.

I am using a kinda beginners code to compare each and every row's ID in a
for loop and deriving the index. If my datatable has >10000 rows, this
procedure is very inefficient.

Is there any efficient way to retrieve a row index?

TIA,
Diffi
Nov 19 '05 #1
1 1684
On Wed, 30 Mar 2005 14:45:04 -0600, Diffident
<Di*******@disc ussions.microso ft.com> wrote:
Hello All,

Was wondering if we could retrieve the index of a particular row from a
dataset's table based on the filter criteria for the row?

For example, I have 4 rows in my datatable which is inside a dataset.
One of
the columns is "ID" field. If I want to retrieve the row index of a row
with
ID = 10, is there any API which I could use in .NET framework.

I am using a kinda beginners code to compare each and every row's ID in a
for loop and deriving the index. If my datatable has >10000 rows, this
procedure is very inefficient.

Is there any efficient way to retrieve a row index?

TIA,
Diffi


Is the sort based on "ID"? If so, you can use a DataView:

http://groups-beta.google.com/group/...11bccc202ca28c

--
Craig Deelsnyder
Microsoft MVP - ASP/ASP.NET
Nov 19 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
2268
by: Rushabh Dadbhawala | last post by:
Problem: I am fetching data from the database, storing it in a dataSet, and binding it with a Data Grid. The DataGrid controls allows sorting. The problem is that when the data is sorted on one of the columns in the Data Grid, and I then try to retrieve the selected row using the "SelectedRowIndex", I get the row as per the original order of data. Eg: If the order of rows is: C - A - B, which after sorting becomes A - B - C. Now, if I...
8
2046
by: Christopher Weaver | last post by:
I'm having the hardest time doing the simplest thing. I have a DataGrid bound to a table in a master detail DataRelation within a DataSet relTaskActivities = new DataRelation("TaskActivities", parentCol, childCol); dsTaskActivities.Relations.Add(relTaskActivities); dgActivity.SetDataBinding(dsTaskActivities, "Tasks.TaskActivities"); This works fine. I have a properly behaving master detail relationship.
3
1706
by: Chris Thunell | last post by:
I have a Listbox on an vb aspx web page. When i select something in the listbox i do not get a selected value or selected index. The selected index is always -1. Any thoughts would be greatly appreciated! Chris Thunell cthunell@pierceassociates.com Here is my code: loading:
3
9756
by: Justin | last post by:
I have created a dataset with two tables and an insert command, I need to be able to retreive the Key Identity after inserting into table "A" for use in table "B". Should I use ExecuteScalar() or is there a better solution? Thanks, Justin.
0
276
by: Diffident | last post by:
Hello All, Was wondering if we could retrieve the index of a particular row from a dataset's table based on the filter criteria for the row? For example, I have 4 rows in my datatable which is inside a dataset. One of the columns is "ID" field. If I want to retrieve the row index of a row with ID = 10, is there any API which I could use in .NET framework. I am using a kinda beginners code to compare each and every row's ID in a
6
5689
by: TB | last post by:
Hi All: Here´s a very simple question: I have created a datatable inside a dataset, and subsequently selected a particular row using certain criteria. How do get the index number of that particular row? There doesn´t seem to be property like "mydatable.currentlyselectedrowindex" or "myrow.indexnumber". Any suggestions will be highly appreciated.
3
4750
by: DavidB | last post by:
New to .net....sorry if this seems repetitive I have a dataset ordered by date (SQLDataAdapter SelectCommand uses Order By) and want to find a record by a UniqueID(Identity Column). Then I want to change the position (BindingContext) in the dataset to have all my bound controls reflect the data in the found record - and the related records/tables. Problem is, it appears it can't be done.... The Dataset has to be ordered by the date...
8
2273
by: Joe Rattz | last post by:
Ok, I can't believe what I am seeing. I am sure I do this other places with no problems, but I sure can't here. I have some code that is indexing into the ItemArray in a DataSet's DataRow. I basically want to change the value of the data stored at a particular index in the ItemArray. Ideally, I would like for my code to look like this (pay attention to the index of ItemArray): row.ItemArray = itemArray.ToString().Substring(3);
1
9444
by: jimmyfo | last post by:
Hi, I recently wrote an ASP.Net web application in VS2005 and published (using VS2005 Publish feature) it to a relatively clean machine with ASP.Net 2.0 and MDAC 2.8 installed on it. However, when I try to create my SQL connection in the code-behind, I get the following error. I tried to register the DLL using regsvr32 but that errored out saying, "dllregisterserver entry point was not found". Any ideas? Retrieving the COM class factory...
5
2648
by: Randy Smith | last post by:
Hi ALL, I wonder if anyone has been using n-tier to bind to a GridView control by using the ObjectDataSource. This is our first OOP web application, and we have no tables. Right now we are simply working with objects in memory. So, it appears as though Microsoft requires that our datamapper classes reside inside a folder called "App_Code", and NO WHERE ELSE. So, has anyone successfully been able to place their datamappers in a...
0
8676
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9161
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9029
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
6522
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5860
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4370
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4619
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3050
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2006
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.