Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Find specific data row in Dataset

Reply
Thread Tools

Find specific data row in Dataset

 
 
Grey
Guest
Posts: n/a
 
      09-22-2004
I have a dataset, is it possible to find one specific row of data with some
criteria?? For example There are two fields, Field1 and Field2 in the
datatable of dataset. i need to search is Field1 column has value 'a', if
so, i need to get the data of Field2.

Million thanks


 
Reply With Quote
 
 
 
 
GrantMagic
Guest
Posts: n/a
 
      09-22-2004
You can loop through a dataset to find that value

DataSet ds = new DataSet("table");
//FILL THE DATASET
string RequiredValue;

foreach(DataRow dr in ds.Table["tale"].Rows)
{
if(dr[0].ToString == "a") //WHERE 0 is the field1
{
RequiredValue = dr[1].ToString(); //WHERE 1 is field2
}
}


If you don't know the name of the datatable before hand, you can loop
through those too

foreach(DataTable dt in ds.Tables)
{
foreach(DataRow dr in dt.Rows)
{
if(dr[0].ToString == "a") //WHERE 0 is the field1
{
RequiredValue = dr[1].ToString(); //WHERE 1 is field2
}
}
}

"Grey" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
>I have a dataset, is it possible to find one specific row of data with some
> criteria?? For example There are two fields, Field1 and Field2 in the
> datatable of dataset. i need to search is Field1 column has value 'a', if
> so, i need to get the data of Field2.
>
> Million thanks
>
>



 
Reply With Quote
 
 
 
 
Hermit Dave
Guest
Posts: n/a
 
      09-22-2004
DataRows[] drFiltered =
yourDataSet.Tables[0].Select("yourcolumnfiltercriteria");
if drFiltered.Length != 0 then you know you have the records filtered.

yourcolumnfiltercriteria could be
your columnname with any of the operators = != > < >= <= etc etc. look it up

--

Regards,

Hermit Dave
(http://hdave.blogspot.com)
"Grey" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
>I have a dataset, is it possible to find one specific row of data with some
> criteria?? For example There are two fields, Field1 and Field2 in the
> datatable of dataset. i need to search is Field1 column has value 'a', if
> so, i need to get the data of Field2.
>
> Million thanks
>
>



 
Reply With Quote
 
 
 
Reply

Thread Tools

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
ie6 Insert Row at specific Row Index of Table Giggle Girl Javascript 18 02-07-2006 07:54 AM
ok I can do a totals row but how about a percentage row after each data row D ASP .Net Datagrid Control 0 05-23-2005 04:10 PM
Updating a specific Row in a DataSet =?Utf-8?B?SnVzdGlu?= ASP .Net 1 03-13-2005 02:36 PM
Referencing Dataset row not Datagrid row Craig ASP .Net 2 11-02-2004 05:27 PM
How to find grid's row that matches row in dataset IK ASP .Net Datagrid Control 0 09-15-2003 05:40 PM



Advertisments