Hi All,

I currently have two dropdown lists which are bound to a SQL DataSource. The two controls have the following properties set:

  1. AppendDataBoundItems = True
  2. AutoPostBack = False
  3. CausesValidation = True


When a Button Click Event fires, the dropdown lists default to the first value in the SQL DataSource.

I've removed the DataBinding and manually added items and upon clicking a button, the value originally selected in the dropdown list remains as is.

Below is the code I am using to bind one of the drop down lists.

VB Code:
  1. Protected Sub BindAuthorityDDL()
  2.  
  3.         Me.ddlAuthority.Items.Clear()
  4.  
  5.         Try
  6.  
  7.             Using da As New SqlDataAdapter("SELECT Activity, TimeUnit FROM tblATU WHERE FieldName = 'ddlAuthority' ORDER BY Activity ASC", ConfigurationManager.ConnectionStrings("DEEstimatorConnectionString").ToString())
  8.  
  9.                 Dim dt As New DataTable
  10.                 da.Fill(dt)
  11.                 da.Dispose()
  12.                 Me.ddlAuthority.DataSource = dt
  13.                 Me.ddlAuthority.DataTextField = "Activity"
  14.                 Me.ddlAuthority.DataValueField = "TimeUnit"
  15.                 Me.ddlAuthority.DataBind()
  16.  
  17.             End Using
  18.  
  19.         Catch ex As Exception
  20.  
  21.         End Try
  22.  
  23.     End Sub

VB Code:
  1. Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
  2.  
  3.         If Not Page.IsPostBack Then
  4.  
  5.             BindAuthorityDDL()
  6.  
  7.         End If
  8.  
  9.     End Sub