Bind PhotoSets to DropDownList

Topics: Developer Forum
Mar 15, 2011 at 9:54 PM

I'm new to vb.net and FlickrNet. I have got the FlickrNet demo working but I now need to bind Photosets to an asp.net dropdownlist.

Can someone please point me in the right direction. As you can tell from the question .... I am just a beginner

Coordinator
Mar 15, 2011 at 10:12 PM

Simply set DataTextField to the field you want to display (probably "Name") and DataValueField to "PhotosetId" then set DataSource to the PhotosetsCollection.

If you are having problems getting this working then show us some code (and make it as simple an example as you can).

Sam

Mar 16, 2011 at 1:03 AM

Hi Sam,

Forgot to say a huge thanks for all your work so far. Awesome!

Here is my code behind page default2.aspx.vb

Imports FlickrNet
Partial Class Default2
    Inherits System.Web.UI.Page

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        Dim flickr As New Flickr()

        Dim PhotoSetOwner = ConfigurationManager.AppSettings("FlickrUserId")
        Dim PhotoSetList = flickr.PhotosetsGetList(PhotoSetOwner)
        DropDownListPhotoSets.DataSource = PhotoSetList
        DropDownListPhotoSets.DataBind()
        DropDownListPhotoSets.DataTextField = "Title"
        DropDownListPhotoSets.DataValueField = "PhotosetId"
    End Sub
End Class



and my default2.aspx contains a dropdownlist

<asp:DropDownList ID="DropDownListPhotoSets" runat="server" >
    </asp:DropDownList>

I'm really struggling though

Coordinator
Mar 16, 2011 at 8:08 AM

I think you need to call DataBind() after you've set DataTextField and DataValueField. I'll give it a go myself later.

Sam