Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 3.5 > ASP.NET 3.5 Professionals
Password Reminder
Register
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
 
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old April 11th, 2012, 04:01 AM
Registered User
Points: 5, Level: 1
Points: 5, Level: 1 Points: 5, Level: 1 Points: 5, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
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"]);
}
}
  #2 (permalink)  
Old April 11th, 2012, 07:18 AM
Friend of Wrox
Points: 2,473, Level: 20
Points: 2,473, Level: 20 Points: 2,473, Level: 20 Points: 2,473, Level: 20
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: May 2004
Location: India
Posts: 642
Thanks: 0
Thanked 43 Times in 42 Posts
Default

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


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


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



All times are GMT -4. The time now is 12:45 AM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.