Joel
Joel

Reputation: 359

ASP.NET AcessDataSource and dropdownlist

I'm using visual studio 2008 with .net 3.5. I have an AccessDataSource that is linked to a access database. I have a dropdownlist that use the AccessDataSource. Everything was done with the wizard and everything was working just fine.

At the page load I decided to call the SelectedIndexChanged of my dropdownlist to update something with the selectedValue but to my suprise the selectedValue was an empty string.

To resolve the problem I put this in my page_load Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load If Not IsPostBack Then

        ddlAnniversaire.DataBind()
        ddlAnniversaire_SelectedIndexChanged(Nothing, Nothing)
    End If

End Sub

If I don't put ddlAnniversaire.DataBind() the ddlAnniversaire.selectedValue is "" in my method. Why?
Normally when is the ddlAnniversaire.DataBind() called?

Thanks

Upvotes: 0

Views: 288

Answers (1)

Jonathan
Jonathan

Reputation: 1892

The DataBind() event occurs after the Page_Load and in the PreRender event of the Page Lifecycle (MSDN link).

Hope this helps, JP

Upvotes: 1

Related Questions