How to get value of one complete row in data table.
Hi,
You can read DataRow for each DataColumn in DataTable. I have attached a screenshot for same.Here item is of type DataColumn.
Thank you.
IS there any other way to compare to columns value of excel without looping…?
You can do some magic actually:
I will reffer to an older post where i explain how working with List instead of using Datatables can help when you need to work with dataTables.
What are you trying to do?
I will give you some examples:
List of first columns values as string :
string.join(“,”, dataTable.Rows.Cast(of DataRow).Select(function(row) row(0).tostring).tolist)
Getting totals for data subgroups:
In order to understand the example Column1=Footbal Team Column2=Cost
Total cost of all player on each team: it could be done with only one line code but would be more difficult
for each (teamName in dataTable.Rows.Cast(of DataRow).Select(function(row) row(0).tostring).distinct)
accumulativeCost = dataTable.Rows.Cast(of DataRow).Where(function(row) row(0).tostring = teamName).Sum(function(row) row(1))
You can do almost anything with linq give us a detailed explanation about your problem and we can provide you a detailed answer
string.join(“,”, dataTable.Rows.Cast(of DataRow).Select(function(row) row(0).tostring).tolist)
This is working only for the first item. when coming to second looping the output data is in dupilcate format.
Example: 1st line: “abc” and “def” output: “abc def”
2nd line: “123” and “456” output: “123 123 123 456 456 456”