Solved

Populate DropDown with LINQ

Posted on 2010-11-29
5
466 Views
Last Modified: 2012-05-10
Just starting to work with LINQ.  I want to populate a dropdown from a table that contains two fields: Role and Role_ID_pk.
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''

        ' Populate the Ticket Master Role DropDown

        ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''

        Using myDataContext As New TicketStoreDataContext()

            Dim AllTicketMasterRoles = From Ticket_Master_Role In myDataContext.TICKET_MASTER_ROLEs _

                                       Select Ticket_Master_Role.Role, Ticket_Master_Role.Role_ID_pk



            Dim ddTicketMasterRoles As New DropDownList

            ddTicketMasterRoles = CreateUserWizard1.CreateUserStep.ContentTemplateContainer.FindControl("ddTicketMasterRoles")

            ddTicketMasterRoles.DataSource = AllTicketMasterRoles

            ddTicketMasterRoles.DataTextField = ?????????

            ddTicketMasterRoles.DataValueField = ????????

            ddTicketMasterRoles.DataBind()



        End Using

Open in new window

0
Comment
Question by:rrhandle8
  • 2
  • 2
5 Comments
 
LVL 29

Expert Comment

by:Kumaraswamy R
ID: 34236503
0
 
LVL 29

Accepted Solution

by:
Kumaraswamy R earned 125 total points
ID: 34236511
0
 

Author Comment

by:rrhandle8
ID: 34236524
Already read all three.  No help.
0
 
LVL 2

Expert Comment

by:getnitincr
ID: 34236526
0
 

Author Comment

by:rrhandle8
ID: 34236539
Oops!  I did not read the last one: http://social.msdn.microsoft.com/forums/en-US/linqprojectgeneral/thread/f52f7a08-6a9e-4cd8-81e6-6f5dc3104169/
Just added the field names.

            ddTicketMasterRoles.DataTextField = "Role"
            ddTicketMasterRoles.DataValueField = "Role_ID_pk"
0

Featured Post

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Put text in a picture ASP.NET C# 2 37
Text in tooltip bound field bridview 3 30
varchar (max) 5 29
Adjust the position 3 16
In an ASP.NET application, I faced some technical problems. In this article, I list them out and show the solutions that I found.  I hope it will be useful. Problem: After closing a pop-up window, the parent page should be refreshed automaticall…
A quick way to get a menu to work on our website, is using the Menu control and assign it to a web.sitemap using SiteMapDataSource. Example of web.sitemap file: (CODE) Sample code to add to the page menu: (CODE) Running the application, we wi…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

744 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now