Wrox Programmer Forums
ASP.NET 3.5 Professionals If you are an experienced ASP.NET programmer, this is the forum for your 3.5 questions. Please also see the Visual Web Developer 2008 forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 3.5 Professionals 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 April 11th, 2012, 04:01 AM
Registered User
Join Date: Apr 2012
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default searching record from DataTable

i have used below code to search from a data table that is retrieved from the viewstate. However when i use the = sign in the expression, it is not returning any values for the search. However if i use > sign, it returns all the values. Can anyone let me know if I am doing anything wrong:

DataTable myDT =(DataTable) ViewState["myQuestions"];

myDT.PrimaryKey = new DataColumn[] { myDT.Columns["SlNo"] };

String expr = "slNo=3";
DataRow[] foundRows = myDT.Select(expr);

for (int i = 0; i < foundRows.Length; i++)
lblSlNo.Text =Convert.ToString (foundRows[i]["SlNo"]);
Old April 11th, 2012, 07:18 AM
Friend of Wrox
Join Date: May 2004
Posts: 642
Thanks: 0
Thanked 43 Times in 42 Posts

You can do the following:
DataRow[] dr = table1.Rows.Find("slNo = 3");
Om Prakash Pant
Click the "Thanks" button if this post helped you.

Similar Threads
Thread Thread Starter Forum Replies Last Post
check existence of a record in a database before inserting a new record ibmkahm ASP.NET 4 General Discussion 1 November 15th, 2010 03:44 AM
Find Last Record and Add new keyed record causualuser Access VBA 3 February 9th, 2009 08:24 AM
Datatable Limno .NET Framework 1.x 0 May 28th, 2008 02:37 PM
DataTable and Database collie ASP.NET 1.x and 2.0 Application Design 3 August 7th, 2007 11:56 AM
Record locking - user needs the next queued record cbtoolkit SQL Server 2000 0 December 6th, 2004 08:29 AM

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