Wrox Programmer Forums
Go Back   Wrox Programmer Forums > C# and C > C# 1.0 > C#
|
C# Programming questions specific to the Microsoft C# language. See also the forum Beginning Visual C# to discuss that specific Wrox book and code.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the C# section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old August 1st, 2007, 02:22 PM
Authorized User
 
Join Date: Mar 2004
Posts: 74
Thanks: 0
Thanked 0 Times in 0 Posts
Default Find a Row in Datatable

I have a datatable with three columns (ItemID, ItemPrice, ItemDescription). I was trying to find a specific row (the item price of the supplied ItemID) based on ItemID supplied. I have the following code but it returns null all the time. Did i miss something here ?


 DataTable dt = ds.Tables[0];
 DataColumn[] dc = new DataColumn[1];
 dc[0] = "ItemID"];
 dt.PrimaryKey = dc;
 DataRow dr = dt.Rows.Find(1); // 1 is the itemID
The problem is dr is always null.

any help would be appreciated.
 
Old August 1st, 2007, 03:01 PM
Authorized User
 
Join Date: Mar 2004
Posts: 74
Thanks: 0
Thanked 0 Times in 0 Posts
Default

figured out. the data itself was wrong. Thanks





Similar Threads
Thread Thread Starter Forum Replies Last Post
find the FIRST USED row/column? crmpicco Excel VBA 3 July 23rd, 2013 12:52 PM
Add a Row to a DataTable in a specified location infernokodiak C# 1 January 16th, 2006 05:32 PM
Find Dictinct Value In DataTable liduwan Classic ASP Databases 4 December 13th, 2005 09:12 AM
Find Datagrid selected row vije ASP.NET 1.0 and 1.1 Basics 3 August 23rd, 2005 10:05 AM
Find total row count when databinding guppyheart BOOK: ASP.NET Website Programming Problem-Design-Solution 0 September 17th, 2003 07:40 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.