Solved

Populate DropDown with LINQ

Posted on 2010-11-29
5
468 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Set cookies HttpOnly and Secure 4 114
Getting multiple values from a dataset ASP.NET(VB) 3 37
Message not shown 5 34
Help with C#, MVC, razor. 6 23
This article discusses the ASP.NET AJAX ModalPopupExtender control. In this article we will show how to use the ModalPopupExtender control, how to display/show/call the ASP.NET AJAX ModalPopupExtender control from javascript, how to show/display/cal…
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…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
Hi friends,  in this video  I'll show you how new windows 10 user can learn the using of windows 10. Thank you.

863 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

27 Experts available now in Live!

Get 1:1 Help Now