Listview Image Gallery Select Based on Current User

2 posts, 0 answers
  1. Michael
    Michael avatar
    3 posts
    Member since:
    Sep 2008

    Posted 28 Jan 2014 Link to this post

    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
    Return _photos
    End Function
  2. Kostadin
    Kostadin avatar
    1733 posts

    Posted 31 Jan 2014 Link to this post

    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.

    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.
Back to Top