Isabell
asked on
How do I get multiple column values from data table.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Here is how I would approach it:
or, if you just want the First and Last name, you can do:
//select record(s) to data rows
DataRow[] childRow = dt.Select("PersonId = 4");
//if at least one record is found
if(childRow.Any())
{
//copy rows to a datatable
DataTable childDt = childRows.CopyToDataTable();
}
or, if you just want the First and Last name, you can do:
var test = from row in dt.AsEnumerable()
where row.Field<int>("PersonId") == 4
select new {First = row.Field<string>("FirstName"), Last = row.Field<string>("LastName")};
something like
PersonID = dt.Rows(0).Columns(0)
LastName = dt.Rows(0).Columns(1)
....