TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
C# Corner
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Remove Column from DataTable if All column values are NULL
Shantanu Puranik
May 04
2016
Code
9.6
k
0
0
facebook
twitter
linkedIn
Reddit
WhatsApp
Email
Bookmark
expand
for
(
int
col = dataTable.Columns.Count - 1; col >= 0; col--)
{
bool
removeColumn =
true
;
foreach
(DataRow row
in
dataTable.Rows)
{
if
(!row.IsNull(col))
{
removeColumn =
false
;
break
;
}
}
if
(removeColumn) dataTable.Columns.RemoveAt(col);
}
Remove Column from DataTable
Remove null column
DataTable