ObjectDataSource a little help

G

Guest

I have something that works, but it only returns one row of data when i
create an ObjectDataSource with it and bind it to a gridview so i need a
little help with this (thanks)

as simple as it gets
1. my class:
Imports Microsoft.VisualBasic
Public Class radioShowFiles
Private _szFileName As String
Public Property szFileName() As String
Get
Return _szFileName
End Get
Set(ByVal value As String)
_szFileName = value
End Set
End Property
End Class
2.
the functions that allows it to bind:
Public Function fn_getallRadioShows() As DirectoryInfo
Dim ri As System.IO.DirectoryInfo = New
System.IO.DirectoryInfo("c:\websites\arlnewlook\radioshows")
Return ri
End Function
Function fn_rtn() As radioShowFiles
Dim rsf As radioShowFiles = New radioShowFiles
Dim ri As DirectoryInfo = Me.fn_getallRadioShows
Dim diar1 As IO.FileInfo() = ri.GetFiles()
Dim dra As IO.FileInfo
For Each dra In diar1
rsf.szFileName = dra.Name
Next
Return rsf
End Function
End Class
I know why it's only including the last row of data, but i am sorry to say i
don't know what to do to change it! I know i'm very close.
THANKS!
KES
 
G

Guest

revised: this one works, but i have no idea if this is the best way to do
this!!!
(Again this is a basic no-noth'n example, but it does work)
radioShowFies: just the file name
Imports Microsoft.VisualBasic
Public Class radioShowFiles
Sub New()

End Sub
Sub New(ByVal p_FileName As String)
Me.szFileName = p_FileName
End Sub
Private _szFileName As String
Public Property szFileName() As String
Get
Return _szFileName
End Get
Set(ByVal value As String)
_szFileName = value
End Set
End Property
End Class
------------------
Ther object that will bind to a gridview (just change thedir path and it
should workfor you too)
Imports Microsoft.VisualBasic
Imports System.IO
Imports System.Collections.Generic
Public Class RadioShowFunctions

Public Function fn_getallRadioShows() As DirectoryInfo
Dim ri As System.IO.DirectoryInfo = New
System.IO.DirectoryInfo("c:\websites\arlnewlook\radioshows")
Return ri
End Function
Function fn_rtn() As List(Of radioShowFiles)
Dim shows As New List(Of radioShowFiles)
Dim ri As DirectoryInfo = Me.fn_getallRadioShows
Dim diar1 As IO.FileInfo() = ri.GetFiles()
Dim dra As IO.FileInfo
For Each dra In diar1
shows.Add(New radioShowFiles(dra.Name))
Next
Return shows
End Function
End Class

i really want comments on this because i have no contact with other
programmers other than this news group!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top