Move values from Datatable to Gridview columns based on values

I have a datatable with the following
ORID DATE TYPE HOURS WKDATE PUDATE PUINOUT PUTIME PUINOUT1 PUTIME1
79159 05/16/2009 OT 8.00 20090516 20090516 I 443 O 1322
79159 05/18/2009 WH 8.00 20090518 20090518 I 638 O 1522
79159 05/19/2009 WH 8.00 20090519 20090519 I 643 O 1528
79159 05/20/2009 OT 2.20 20090520 20090520 I 446 O 1530
79159 05/20/2009 WH 8.00 20090520 20090520 I 446 O 1530

My Gridview has  Date, In,Out, Overtime, etc

How can I place the Hours value into my Overtime Column when Type = OT?
LVL 6
ITHelper80Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Kyle AbrahamsSenior .Net DeveloperCommented:
I would create a new datatable, call tableOT

open a datareader on first datatable
parse through info.

if dr("Type") = "OT"
  'add value to OT column
else
  row("Overtime") = 0 'yes, no??
 'do something else with other values?
end if
TableOT.Rows.Add(row)

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
satheeshmCommented:
I guess, you want to show hours in overtime column of datagrid, in that case you can use row databound event

if e.row.rowtype = datarow{
if e.row["Type"] == "OT"{
e.row["type"] = e.row["hours"]
}
}
0
ITHelper80Author Commented:
THank ged...Im going to try your solution first since you posted first.

Ive got one question, how can I bind the value of the reader to my columns?
Ive tried this but get an error about a readonly property.
 AS400DT.Columns("Overtime") = readerobjrs7.Item("Hours").ToString
0
ITHelper80Author Commented:
I was able to figure out how to bind the rows with a reader. Thanks for the suggestions.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
ASP.NET

From novice to tech pro — start learning today.