How do you use LINQ (C#) to select the value in a particular column for a particular row in a datatable. The equivalent SQL would be:<
Use linq and set the data table as Enumerable and select the fields from the data table field that matches what you are looking for.
Example
I want to get the currency Id and currency Name from the currency table where currency is local currency, and assign the currency id and name to a text boxes on the form:
DataTable dt = curData.loadCurrency();
var curId = from c in dt.AsEnumerable()
where c.Field("LocalCurrency") == true
select c.Field("CURID");
foreach (int cid in curId)
{
txtCURID.Text = cid.ToString();
}
var curName = from c in dt.AsEnumerable()
where c.Field("LocalCurrency") == true
select c.Field("CurName");
foreach (string cName in curName)
{
txtCurrency.Text = cName.ToString();
}