PDA

Click to See Complete Forum and Search --> : Using ASP.NET Where am I wrong


bobbynad
Jul 11th, 2004, 05:26 AM
Imports System.ComponentModel
Imports System.Windows.Forms
Imports System.Web.UI

Public Class WebForm1
Inherits System.Web.UI.Page


Protected WithEvents DropDownList1 As System.Web.UI.WebControls.DropDownList
Protected WithEvents ListBox1 As System.Web.UI.WebControls.ListBox
Protected WithEvents Button1 As System.Web.UI.WebControls.Button
Private AryFiles() As FileList = New FileList(100) {}

Protected WithEvents Label1 As System.Web.UI.WebControls.Label
Protected WithEvents DataGrid1 As System.Windows.Forms.DataGrid



Dim FilCount As Integer
#Region " Web Form Designer Generated Code "

'This call is required by the Web Form Designer.
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()

End Sub

Private Sub Page_Init(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Init
'CODEGEN: This method call is required by the Web Form Designer
'Do not modify it using the code editor.
InitializeComponent()
End Sub

#End Region

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
FilCount = 0
'Put user code to initialize the page here
End Sub



Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
AryFiles.Clear(AryFiles, 0, 100)
FilDisplay("C:\Documents and settings")
DataGrid1.DataSource = AryFiles
GridFormat()
End Sub
Private Sub FilDisplay(ByVal Str As String)
Dim Fld As Scripting.Folder
Dim Fl As Scripting.File
Dim FSO = New Scripting.FileSystemObject()
For Each Fl In FSO.getfolder(Str).files
'AryFiles(0) = New FileList("Hello", "Bolo", "12/05/2006")
AryFiles(UBound(AryFiles, 1) + 1) = New FileList(Fl.Name, Fl.Type, Fl.DateCreated)


'FilCount = FilCount + 1
Next
For Each Fld In FSO.getfolder(Str).subfolders
FilDisplay(Str & "\" & Fld.Name)
Next
End Sub
Private Sub GridFormat()
Dim gs As DataGridTableStyle = New DataGridTableStyle()
gs.MappingName = AryFiles.GetType().Name

Dim cs As DataGridTextBoxColumn = New DataGridTextBoxColumn()
cs.MappingName = "FileName"
cs.HeaderText = "File Name"
cs.Alignment = HorizontalAlignment.Center
cs.Width = 100
gs.GridColumnStyles.Add(cs)

cs = New DataGridTextBoxColumn()
cs.MappingName = "FileType"
cs.HeaderText = "File Type"
cs.Alignment = HorizontalAlignment.Left
cs.Width = 75
gs.GridColumnStyles.Add(cs)

cs = New DataGridTextBoxColumn()
cs.MappingName = "FileCreated"
cs.HeaderText = "Created On"
cs.Alignment = HorizontalAlignment.Left
cs.Width = 75
gs.GridColumnStyles.Add(cs)


DataGrid1.TableStyles.Add(gs)

gs.MappingName = AryFiles.GetType().Name

End Sub

Private Sub ListBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ListBox1.SelectedIndexChanged

End Sub
End Class


Public Class FileList

Private m_FileName As String
Private m_FileType As String
Private m_FileCreated As Date


Public ReadOnly Property FileName()
Get
FileName = m_FileName
End Get
End Property

Public ReadOnly Property FileType()
Get
FileType = m_FileType
End Get
End Property

Public ReadOnly Property FileCreated()
Get
FileCreated = m_FileCreated
End Get
End Property



Public Sub New(ByVal FileName As String, ByVal FileType As String, ByVal FileCreated As Date)
Me.m_FileName = FileName
Me.m_FileType = FileType
Me.m_FileCreated = FileCreated
End Sub

End Class


This is the above code , Please let me know where am I wrong

1.The Datagrid is not displayed
2.Ubound of the array dosen't work

Please Help

venerable bede
Jul 12th, 2004, 04:21 AM
I think you need to tell us all what went wrong first.

venerable bede
Jul 12th, 2004, 04:24 AM
I have noticed an end sub all on its own !

bobbynad
Jul 12th, 2004, 06:47 AM
Firstly , The datagrid dosen't appear.
Secondly , arrays ubound dosen't work it says that the array out of bound.