title: Populate dropdownlist asynchronously
body: <p>I have a page that will populate two dropdownlist by loading items from SQL Server during Page_Load event, so, when opening the page it may take some time to load. Currently, the dropdownlist will load asynchronously but it still will slow down the page loading. How can i load those dropdownlist after the page is completely loaded?</p>
  
  <pre><code>Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
     If Not IsPostBack Then
        LoadDDL()
     End If
  End Sub
  
  Public Sub LoadDDL()
      Try
          Dim cnnStr As String = DBMgr1.asyncADOCnnStr("SQLDS")
  
  
          '===== Load Scheme DDL =====
          Dim cnnScheme As SqlConnection = New SqlConnection(cnnStr)
          cnnScheme.Open()
  
          Dim SchemeStr As String = "SELECT " &amp; _
                                      "CASE CODE " &amp; _
                                          "WHEN 'P-PFC' THEN 'PFC' " &amp; _
                                          "ELSE CODE " &amp; _
                                      "END AS [SchemeCode], " &amp; _
                                      "CASE DESCR " &amp; _
                                          "WHEN 'P-PFC' THEN 'P-PFC/C-PFC' " &amp; _
                                          "ELSE CODE " &amp; _
                                      "END AS [SchemeName] " &amp; _
                                  "FROM i_Library WHERE MODULE = 'SYS' AND TYPE = 'Schemes' AND Stat1 = 'ACT' " &amp; _
                                  "AND Code &lt;&gt; 'C-PFC' " &amp; _
                                  "ORDER BY DESCR DESC"
  
          Dim cmdScheme As New SqlCommand(SchemeStr, cnnScheme)
          cmdScheme.CommandType = CommandType.Text
          Dim arScheme As IAsyncResult = cmdScheme.BeginExecuteReader()
          '===== Load Scheme DDL =====
  
  
          '===== Load Branch DDL =====
          Dim cnnBranch As SqlConnection = New SqlConnection(cnnStr)
          cnnBranch.Open()
  
          Dim BranchStr As String = "" &amp; _
                                      "SELECT Distinct TeamCode " &amp; _
                                      "FROM v_staff " &amp; _
                                      "ORDER BY TeamCode " &amp; _
                                      " "
          Dim cmdBranch As New SqlCommand(BranchStr, cnnBranch)
          cmdBranch.CommandType = CommandType.Text
          Dim arBranch As IAsyncResult = cmdBranch.BeginExecuteReader()
          '===== Load Branch DDL =====
  
  
          '===== Load Region Code DDL =====
          Dim cnnRegion As SqlConnection = New SqlConnection(cnnStr)
          cnnRegion.Open()
  
          Dim RegionStr As String = "" &amp; _
                                      "SELECT Distinct RegionCode " &amp; _
                                      "FROM v_staff " &amp; _
                                      "WHERE RegionCode IS NOT NULL " &amp; _
                                      "ORDER BY RegionCode " &amp; _
                                      " "
          Dim cmdRegion As New SqlCommand(RegionStr, cnnRegion)
          cmdRegion.CommandType = CommandType.Text
          Dim arRegion As IAsyncResult = cmdRegion.BeginExecuteReader()
          '===== Load Region Code DDL =====
  
  
          'wait for the Scheme Query to return result
          arScheme.AsyncWaitHandle.WaitOne()
          Dim drScheme As SqlDataReader = cmdScheme.EndExecuteReader(arScheme)
          While drScheme.Read
              ddlScheme.DataSource = drScheme
              ddlScheme.DataTextField = "SchemeName"
              ddlScheme.DataValueField = "SchemeCode"
              ddlScheme.DataBind()
  
              ddlScheme.Items.Insert(0, "Select Scheme")
              ddlScheme.Items(0).Value = CMM.sExcVal1
          End While
  
          'wait for the Branch Query to return result
          arBranch.AsyncWaitHandle.WaitOne()
          Dim drBranch As SqlDataReader = cmdBranch.EndExecuteReader(arBranch)
          While drBranch.Read
              ddlBranch.DataSource = drBranch
              ddlBranch.DataTextField = "TeamCode"
              ddlBranch.DataValueField = "TeamCode"
              ddlBranch.DataBind()
  
              ddlBranch.Items.Insert(0, "Select Branch")
              ddlBranch.Items(0).Value = CMM.sExcVal1
          End While
  
          'wait for the Region Query to return result
          arRegion.AsyncWaitHandle.WaitOne()
          Dim drRegion As SqlDataReader = cmdRegion.EndExecuteReader(arRegion)
          While drRegion.Read
              ddlRegionCode.DataSource = drRegion
              ddlRegionCode.DataTextField = "RegionCode"
              ddlRegionCode.DataValueField = "RegionCode"
              ddlRegionCode.DataBind()
  
              ddlRegionCode.Items.Insert(0, "Select Region")
              ddlRegionCode.Items(0).Value = CMM.sExcVal1
          End While
  
          drScheme.Close()
          drBranch.Close()
          drRegion.Close()
          cnnScheme.Close()
          cnnBranch.Close()
          cnnRegion.Close()
  
      Catch ex As Exception
          MSGMgr.errHandlerSys(ex.Message, lblMsg)
      End Try
  End Sub
  </code></pre>