p2p.wrox.com Forums

p2p.wrox.com Forums (http://p2p.wrox.com/index.php)
-   ASP.NET 3.5 Professionals (http://p2p.wrox.com/forumdisplay.php?f=352)
-   -   searching record from DataTable (http://p2p.wrox.com/showthread.php?t=87221)

knadig April 11th, 2012 04:01 AM

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"]);
}
}

om_prakash April 11th, 2012 07:18 AM

You can do the following:
DataRow[] dr = table1.Rows.Find("slNo = 3");


All times are GMT -4. The time now is 08:34 PM.

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