Reputation: 1550
In the Linq after retrieving from the dataset how can i get the column data without using the for each statement?
var query = from alias in ds.Tables[0].AsEnumerable()
where alias.Field<string>("lanename") == ddlLaneController.SelectedItem.Text
select new
{
locname = alias["LocationName"],
locid = alias["locationid"]
};
txtStartLocation.Text = query.Select(a => a["LocationName"]).ToString();
Can i know how can i achieve this?
Thanks, Vara Prasad
Upvotes: 0
Views: 3289
Reputation: 12776
If there is a single resulting row use Single
:
txtStartLocation.Text = query.Single().locname;
Upvotes: 2
Reputation: 174309
I think you want to use First()
:
txtStartLocation.Text = query.First().locname.ToString();
Upvotes: 1