Wiring up Entity Framework to DropDownList ASP.NET.
Prereq --- Setup Entity Framework.
Private Sub FillSource()
ctx = New Context()
Dim qry = From p In ctx.tbl_names
Where p.ACTIVE = True
Order By p.name
Select p.id, p.name
ddlFundSource.DataSource = qry.ToList()
ddlFundSource.DataValueField = id"
ddlFundSource.DataTextField = "name"
ddlFundSource.DataBind()
ddlFundSource.Items.Insert(0, New ListItem("[Any Fund]", "0")) ' Tip if you want to add a default value.
End Sub
Robert Dannelly blog, Over the internet you can find me by "robert dannelly blog". The blog is an ongoing blog of my software engineering over technologies C#, VB.NET, Java, React, JavaScript, .NET Core Current, SQL Server 7 - Current Version, GIT, GitHub, Jira, Azure, AWS and HTML5. “I have not failed. I've just found 10,000 ways that won't work.” Thomas A. Edison, please click on all links to help support this blog. Thank you. “As an Amazon Associate, I earn from qualifying purchases.”
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment