Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

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

Posted on 2014-08-17
1
Medium Priority
?
229 Views
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?
0
Comment
Question by:Mike Miller
1 Comment
 
LVL 52

Accepted Solution

by:
Carl Tawn earned 2000 total points
ID: 40267228
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
                uniqueValues.Add(ddl.SelectedValue)
            Else
                areUnique = False
                Exit For
            End If

        Next

    End Sub

Open in new window

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

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
Hello there! As a developer I have modified and refactored the unit tests which was written by fellow developers in the past. On the course, I have gone through various misconceptions and technical challenges when it comes to implementation. I would…
Despite its rising prevalence in the business world, "the cloud" is still misunderstood. Some companies still believe common misconceptions about lack of security in cloud solutions and many misuses of cloud storage options still occur every day. …
Enter Foreign and Special Characters Enter characters you can't find on a keyboard using its ASCII code ... and learn how to make a handy reference for yourself using Excel ~ Use these codes in any Windows application! ... whether it is a Micr…
Suggested Courses
Course of the Month14 days, 20 hours left to enroll

578 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