.NET Directory to DataGrid
Post # 74 permalink Topic #74 by mreschke on 2008-06-05 11:25:50 (viewed 984 times)

Add a directory of files to a datagrid

For greater control, you can add the file data to a dataset, then bind the dataset to the datagrid.

Bind directory to Data Grid[-][- -][++]

Script Snippet

Changing Displayed Columns[-][- -][++]

With just a default datagrid (AutoGenerateColumns=true) you will get a lot of usefull \
columns, like Name, Path, Size in bytes, Creation/Modify time...

To narrow down the columns you want, goto Property Builder on the dg, select columns.

Bound Column
To simply display data, without events, select Bound Column, Give Header Text, \
Data Field: would be name of the default dg from dirInfo (Name, CreationTime, Extension, Length...)

Button Column
An example of making the Name of the file a LinkButton

Header Text File Name
Text Name
Text Field Name
Command Name download
Button Type LinkButton

Note, in this example, my datagrid has 2 columns, Name and Length, so the ItemDataBound functions converts the size to KB

Script Snippet