troubleshooting Question

Remove empty columns from DataTable before binding to gridview

Avatar of ITHelper80
ITHelper80 asked on
.NET ProgrammingASP.NET
11 Comments1 Solution965 ViewsLast Modified:
Hi,

I am creating a DT with the below columns. Does someone know how I can iterate through each one and remove the column if all the rows are empty?
AS400DT.Columns.Add(New DataColumn("Date", Type.GetType("System.String")))
        AS400DT.Columns.Add(New DataColumn("IN", Type.GetType("System.String")))
        AS400DT.Columns.Add(New DataColumn("OUT", Type.GetType("System.String")))
        AS400DT.Columns.Add(New DataColumn("Reg. Hours Worked", Type.GetType("System.String")))
        AS400DT.Columns.Add(New DataColumn("Vacation", Type.GetType("System.String")))
        AS400DT.Columns.Add(New DataColumn("Absent", Type.GetType("System.String")))
        AS400DT.Columns.Add(New DataColumn("Overtime", Type.GetType("System.String")))
        AS400DT.Columns.Add(New DataColumn("Overtime X2", Type.GetType("System.String")))
        AS400DT.Columns.Add(New DataColumn("Late", Type.GetType("System.String")))
        AS400DT.Columns.Add(New DataColumn("Early Quit", Type.GetType("System.String")))
        AS400DT.Columns.Add(New DataColumn("Holiday", Type.GetType("System.String")))
        AS400DT.Columns.Add(New DataColumn("MULA", Type.GetType("System.String")))
        AS400DT.Columns.Add(New DataColumn("VULA", Type.GetType("System.String")))
        AS400DT.Columns.Add(New DataColumn("Perfect Attendance", Type.GetType("System.String")))
ASKER CERTIFIED SOLUTION
silemone

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 1 Answer and 11 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 11 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros