Monday, 9 June 2014

Remove Columns that contains null values in Data Table - C#



If you have a datatable and you want to delete rows that contains null value from datatable. To do this find the source code below:


            foreach (var column in dt.Columns.Cast<DataColumn>().ToArray())
                {
                    if (dt.AsEnumerable().All(dr => dr.IsNull(column)))
                    {
                        dt.Columns.Remove(column);
                    }
                }

No comments:

Post a Comment

SQL SERVER – Disk Space Monitoring – Detecting Low Disk Space on Server

CREATE PROCEDURE [CSMSDVLP].[DiskSpaceMonitor] @mailProfile nvarchar(500), @mailto nvarchar(4000), @threshold INT, @logfile nvarchar(40...