-2

enter image description here

I have a Datatable like this.Now how can i pick the value from zones based on weight and zone.I am doing this in c#

sindhu jampani
  • 504
  • 3
  • 10
  • 30

2 Answers2

1

Using LINQ Query : You need to use the AsEnumerable() extension for DataTable

    var results = from myRow in myDataTable.AsEnumerable()
                  where myRow.Field<int>("RowNo") == 1
                  select myRow;

AsEnumerable() returns IEnumerable. If you need to convert IEnumerable to a DataTable, use the CopyToDataTable()

Check Here

Community
  • 1
  • 1
Ramy M. Mousa
  • 5,727
  • 3
  • 34
  • 45
-1

If you want to pick cells/rows with criteria. you need to a select clauase in your datatable. Go Here to see some examples

Jonny
  • 401
  • 2
  • 11