3

This is a follow up to my previous question: Filter DirectoryInfo files by date in asp.net

I have a gridview that is populating data from DirectoryInfo.
However, I only want to display certain columns, and customize the column names and the hyperlink value in the row.

My code is:

Dim files As FileInfo() = New DirectoryInfo(strDirectoryPath).GetFiles().Where(Function(x) x.LastWriteTime >= (dtStartDate) AndAlso x.LastWriteTime <= (dtEndDate)).ToArray()  

For Each col In Gridview.Columns
If InStr(1, ",name,Extension,LastWriteTime,", "," & col.ColumnName.ToString.Trim & ",") > 0 Then
                        Dim hfield As HyperLinkField = New HyperLinkField()
                        hfield.DataTextField = col.ColumnName
                        hfield.HeaderText = "<table><tr><td align=""center"">" & col.ColumnName & "</td></tr></table>"
                        gvInvoiceList.Columns.Add(hfield)
                        i += 1
                    End If
Next

Question:
How can I loop through the columns, to display only "name", "extension" and LastWriteTime?

Community
  • 1
  • 1
Troy
  • 1,659
  • 4
  • 19
  • 33

1 Answers1

0

Just customize the GridView columns, listing only the ones you want. Though, if you really want something like a nested table in your column name header, you'll need to step up to a Repeater or ListView instead.

Mark Brackett
  • 84,552
  • 17
  • 108
  • 152