Click here to Skip to main content
15,867,777 members
Please Sign up or sign in to vote.
1.33/5 (2 votes)
See more:
re = ds.Tables[0].Columns["MenuSubCategoryID"]; then How do i take one raw value from re.
Posted

C#
var menuSubCategoryID = ds.Tables[0].Rows[0]["MenuSubCategoryID"];
 
Share this answer
 
Comments
Maciej Los 7-Sep-15 2:53am    
5ed!
DamithSL 7-Sep-15 4:27am    
Thank You
You can achieve that using Linq To Dataset[^].

C#
var result = ds.Tables(0).AsEnumerable()
    .Where(r=>r.Fields<int>("MenuSubCategoryId")==1);

or:
C#
var result = ds.Tables(0).AsEnumerable()
    .Select(r=>r.Field<int>("MenuSubCategoryId"));
foreach(var r in result)
{
    Console.WriteLine("{0}", r.Field<int>("MenuSubCategoryId"));
}


or:
C#
var result = ds.Tables(0).AsEnumerable()
    .FirstOrDefault(r=>r.Fields<int>("MenuSubCategoryId"));



For further information, please see:
LINQ to DataSet Examples[^]
Queries in LINQ to DataSet[^]
Querying DataSets (LINQ to DataSet)[^]
 
Share this answer
 
v2
Comments
DamithSL 7-Sep-15 4:27am    
OP need one row value of given column, so
var result =ds.Tables(0).AsEnumerable().FistOrDefault(r=>r.Field<int>("MenuSubCategoryId"));
Maciej Los 7-Sep-15 5:12am    
"One raw value" might mean everything...

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900