Currently I am using sql and hitting the database to populate a dropdown.
Dim sqlStatement = "SELECT DISTINCT IMLOCN FROM table order by IMLOCN desc"
LocationDropDown.DataSource = DB.sql(dbSalesWeb, sqlStatement)
LocationDropDown.DataTextField = "IMLOCN"
LocationDropDown.DataBind()
LocationDropDown.Items.Insert(0, "ALL")
DB is a custom class and sql returns a Datatable. I'd like to use linq on a datatable that already has the IMLOCN
Protected Sub updateDropDowns(ByVal dt As DataTable)
Dim location = From u In dt.Rows _
Select u("IMLOCN") _
Distinct
LocationDropDown.DataSource = location.ToList
LocationDropDown.DataBind()
End Sub
I've tried
dt.AsEnumerable()
and Dim location = From u In dt.AsEnumerable _
Select u.Field(Of String)("IMLOCN") _
Distinct
I'd like to be able to use linq and I'd like to learn more about it