how to bind a dropdownlist within a datalist

liunx

Guest
I have a datalist that is bound to a dataset. I need to bind a dropdownlist in the datalist to a different datasource.

haven't been able to figure it out :(

any help would be greatly appreciated!The basic idea is here:

<EditItemTemplate>
<asp:DropDownList ID="ddlID" Runat="Server" DataTextField="Something" DataValueField="SomethingElse" DataSource="<%# GetOptions() %>"></asp:dropdownlist>
</EditItemTemplate>

and the server side code

Function GetOptions() as DataTable
'Run your SQL statement and return your datatable
End Function

EricThanks alot. That helps but know i need to know something else.

Im trying to bind the dropdownlist to Directoryinfo.

heres the code im trying to bind.


Dim d1 As DirectoryInfo = New DirectoryInfo(server.mappath("\Files\"))
dropdownlist.DataSource = d1.GetFiles()
dropdownlist.DataBind()


Thats how i bind it outside if a datalist.

how can i conform this to your getoptions() function?


thanks in advance!!Function GetOptions() as ???????
Dim d1 As DirectoryInfo = New DirectoryInfo(server.mappath("\Files\"))
Return d1.GetFiles()
End Function

Do not have VS open so I am not sure what ????? is for GetFiles()

Ericthanks a lot, cured my headache :DGlad I could help....
 
Back
Top