User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the C# section within the Software Development category of DaniWeb, a massive community of 426,480 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,170 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our C# advertiser: Programming Forums
Views: 397 | Replies: 2
Reply
Join Date: Sep 2006
Posts: 104
Reputation: bhavna_816 is an unknown quantity at this point 
Rep Power: 3
Solved Threads: 0
bhavna_816 bhavna_816 is offline Offline
Junior Poster

How to get a datarow from a datable in C#?

  #1  
May 7th, 2008
I have a datatable which is having n no. of rows and each row has a unique field say ID.
Now I want to get a particular row for a specified ID.
eg. there are 5 rows in a datatable and the id's are
1,2,3,4 and 5 and if I want to select a row having ID = 4
What will be the code snippet for that?
Does anybody have any idea?
Thanks in advance,
AddThis Social Bookmark Button
Reply With Quote  
Join Date: May 2006
Posts: 6
Reputation: ckaneta is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 1
ckaneta ckaneta is offline Offline
Newbie Poster

Re: How to get a datarow from a datable in C#?

  #2  
May 7th, 2008
Originally Posted by bhavna_816 View Post
I have a datatable which is having n no. of rows and each row has a unique field say ID.
Now I want to get a particular row for a specified ID.
eg. there are 5 rows in a datatable and the id's are
1,2,3,4 and 5 and if I want to select a row having ID = 4
What will be the code snippet for that?
Does anybody have any idea?
Thanks in advance,


Other than the obvious datatable.Rows[3]

you can do a Select within the table
DataRow[] rws = datatable.Select("ID=4");
Reply With Quote  
Join Date: Apr 2008
Location: Western New York
Posts: 10
Reputation: corwing is an unknown quantity at this point 
Rep Power: 1
Solved Threads: 0
corwing corwing is offline Offline
Newbie Poster

Re: How to get a datarow from a datable in C#?

  #3  
May 7th, 2008
The first thing we need to know to help you is..
How are you handling the datatable?
Is it a two-dimensional array, a class a collection of rows or columns?
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

DaniWeb C# Marketplace
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

Thread Tools Display Modes

Other Threads in the C# Forum

All times are GMT -4. The time now is 4:22 pm.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC