Get multiple selections from drop down lists within a repeater


'this function gets a dropdownlist selected value that is within a repeater along with a label value from a label
called lblStop and adds the values and stop numbers into a dictionary. 
 
 Protected Function getAllSelectedWeekdays() As Dictionary(Of Integer, DateTime)
        'This function is used to build a dictionary of the stops seleced with tkey = stop from the label
        'and tValue from the ddl, the dictionary can then be checked for sequential patterns before any data is allowed to
        'be submitted to the DB (It gets and returns all the stops - whether changed or not--
        Dim theWeekdays As New Dictionary(Of Integer, DateTime)
        For Each ri As RepeaterItem In RepeaterWeekday.Items
            Select Case ri.ItemType
                Case ListItemType.Item, ListItemType.AlternatingItem
                    Dim label_stops As Label = DirectCast(ri.FindControl("lblStop"), Label)
                    Dim ddl_Weekday As DropDownList = DirectCast(ri.FindControl("ddl_Weekday"), DropDownList)
                    Dim theStop As Integer = CType(label_stops.Text, Integer)
                    Dim theSelectedWeekday As DateTime = ddl_Weekday.SelectedValue                
                    theWeekdays.Add(theStop, theSelectedWeekday)
                    Exit Select
            End Select
        Next
        Return theWeekdays
    End Function
Tags: repeater
Last update:
2014-09-15 20:38
Author:
Mark
Revision:
1.0
Average rating:0 (0 Votes)

You cannot comment on this entry

Chuck Norris has counted to infinity. Twice.

Records in this category

Tags