This is a migrated thread and some comments may be shown as answers.

Listview Image Gallery Select Based on Current User

1 Answer 53 Views
ListView
This is a migrated thread and some comments may be shown as answers.
Michael
Top achievements
Rank 1
Michael asked on 29 Jan 2014, 04:22 AM
I have just inserted the Listview Image Gallery in my site and is working properly. 
The Gallery is getting the data from the proper folder however I need it to retrieve the information or images of the Current Logged in user.
I generally accomplish this in Listview with a SqlDatasource and a query of the current logged in UserId.
The Image gallery is getting the data in this manner and I am not sure what additions or changes I need to make to get it to Select based on logged in user UserId.

​Public Shared Function GetData() As IList(Of Photo)
If _photos IsNot Nothing Then
Return _photos
End If

_photos = New List(Of Photo)()
For Each file As String In Directory.GetFiles(HttpContext.Current.Server.MapPath("images/"))
Dim photo = New Photo()
photo.Name = Path.GetFileName(file)

Dim image__1 As Image = Image.FromFile(file)
Using memoryStream = New MemoryStream()
image__1.Save(memoryStream, ImageFormat.Png)
photo.Data = memoryStream.ToArray()
End Using
_photos.Add(photo)
Next
Return _photos
End Function

1 Answer, 1 is accepted

Sort by
0
Kostadin
Telerik team
answered on 31 Jan 2014, 01:27 PM
Hello Michael,

If the images of the current logged user are in a different folders you could point to it and retrieve them from there. Otherwise you have to implement some logic which will allows you to retrieve the correct images for each user. A possible solution is to keep the information about all images of a single user in a list and then loop through all images and retrieve only the ones which are available for the current user.

Regards,
Kostadin
Telerik
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the UI for ASP.NET AJAX, subscribe to the blog feed now.
Tags
ListView
Asked by
Michael
Top achievements
Rank 1
Answers by
Kostadin
Telerik team
Share this question
or