Skip to content

.Net DataTable Column Filter

January 30, 2012
Dim dtNew As DataTable = dt.DefaultView.ToTable(True, {"Column1", "Column2"})


Dim dtNew As DataTable = FilterColumns(dt, {"Column1", "Column2"})
Public Function FilterColumns(ByRef dt As DataTable, ByRef col() As String) As DataTable
    FilterColumns = dt.Copy
    For Each dc As DataColumn In dt.Columns
        If Not col.Contains(dc.ColumnName) Then
        End If
End Function

From → .Net

Leave a Comment

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: