Comparing values of dropdownlists generated by a repeater ASP.NET(vb)

Posted on 2014-08-17
Last Modified: 2014-09-24
I have a series of dropdown lists bound to a repeater control. Upon clicking a button, I want to compare the values of all of the dropdown lists produced by the repeater and validate that none of the selected values match. how do I do this?
Question by:mwmiller78
    1 Comment
    LVL 52

    Accepted Solution

    You could try something like the following:
        Protected Sub Button1_Click(sender As Object, e As EventArgs)
            Dim uniqueValues As New List(Of Integer)
            Dim areUnique As Boolean
            Dim ddl As DropDownList
            areUnique = True
            For Each row As RepeaterItem In Repeater1.Items
                ddl = CType(row.FindControl("DropDown1"), DropDownList)
                If Not uniqueValues.Contains(ddl.SelectedValue) Then
                    areUnique = False
                    Exit For
                End If
        End Sub

    Open in new window

    Obviously you'll need to change the names of the various controls to suit your own environment.

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Highfive + Dolby Voice = No More Audio Complaints!

    Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

    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…
    Problem Hi all,    While many today have fast Internet connection, there are many still who do not, or are connecting through devices with a slower connect, so light web pages and fast load times are still popular.    If your ASP.NET page …
    It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
    Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

    779 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

    16 Experts available now in Live!

    Get 1:1 Help Now