I am struggling to bind a Drop Down List to a Data Source. Please see the code below:
Private _ConString As String
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
_ConString = ConfigurationManager.ConnectionStrings("GeniedbConnection").ConnectionString
SqlDataSourceNicheDuplicates.ConnectionString = _ConString
SqlDataSourceCreatedDate.ConnectionString = _ConString
SqlDataSourceCreatedDate.SelectCommand = "SELECT dateadded distinct convert(varchar,dateadded,103) as dateadded dbNicheDuplicates"
DDLCreatedDate.DataTextField = "dateadded"
DDLCreatedDate.DataValueField = "dateadded"
DDLCreatedDate.DataBind()
end sub
If I run the SQL statement in SQL Studio Manager then many results are returned. What am I doing wrong?
I have spent some time Googling this. For example I looked at this question: Populating an ASP.Net DropDownList using VB.Net coding in code-behind file