set value of dropdownlist inside a repeater
<p>I have a repeater that has a dropdownlist inside it. There is another separate dropdownlist outside the repeater. The user would select a value in this ddl, click a button, and the selected value  would be populated in all the ddl's inside the repeater that are blank. Note: the ddl's have text for selectedvalue (not ints). </p>

<p>Unfortunately my code is not working. </p>

<p>My markup:</p>

<p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
<div class="snippet-code">
<pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;asp:Repeater ID="AttendanceRepeater" runat="server" DataSourceID="AttendanceSqlDataSource" OnItemDataBound="AttendanceRepeater_ItemDataBound"&gt;
                &lt;ItemTemplate&gt;
                    &lt;br /&gt;
                    &lt;table&gt;
                        &lt;tr&gt;
                            &lt;td style="width: 50px"&gt;&lt;/td&gt;
                            &lt;td style="width: 300px"&gt;
                                &lt;asp:Label ID="StudentNameLabel" runat="server" Text='&lt;%# Eval("STUDENT_NAME") %&gt;'&gt;&lt;/asp:Label&gt;
                            &lt;/td&gt;
                            &lt;td style="width: 200px"&gt;
                                &lt;asp:DropDownList ID="AttendStatusDropDownList" runat="server"
                                    SelectedValue='&lt;%# Eval("ATTENDANCE_STATUS") %&gt;'&gt;
                                    &lt;asp:ListItem Value="" Text=""&gt;&lt;/asp:ListItem&gt;
                                    &lt;asp:ListItem Value="ABSENTE" Text="Absent Excused"&gt;&lt;/asp:ListItem&gt;
                                    &lt;asp:ListItem Value="ABSENTU" Text="Absent Unexcused"&gt;&lt;/asp:ListItem&gt;
                                    &lt;asp:ListItem Value="CIN" Text="Chk In No (Absent)"&gt;&lt;/asp:ListItem&gt;
                                    &lt;asp:ListItem Value="CIY" Text="Chk In Yes (Present)"&gt;&lt;/asp:ListItem&gt;
                                    &lt;asp:ListItem Value="NR" Text="Attend Not Reqd"&gt;&lt;/asp:ListItem&gt;
                                    &lt;asp:ListItem Value="PRESENT" Text="Present"&gt;&lt;/asp:ListItem&gt;
                                    &lt;asp:ListItem Value="TM005" Text="Time Missed 005 Min"&gt;&lt;/asp:ListItem&gt;
                                    &lt;asp:ListItem Value="TM010" Text="Time Missed 010 Min"&gt;&lt;/asp:ListItem&gt;
                                    &lt;asp:ListItem Value="TM015" Text="Time Missed 015 Min"&gt;&lt;/asp:ListItem&gt;
                                    &lt;asp:ListItem Value="TM030" Text="Time Missed 030 Min"&gt;&lt;/asp:ListItem&gt;
                                    &lt;asp:ListItem Value="TM045" Text="Time Missed 045 Min"&gt;&lt;/asp:ListItem&gt;
                                    &lt;asp:ListItem Value="TM060" Text="Time Missed 1hr"&gt;&lt;/asp:ListItem&gt;
                                    &lt;asp:ListItem Value="TM075" Text="Time Missed 1hr 15mi"&gt;&lt;/asp:ListItem&gt;
                                    &lt;asp:ListItem Value="TM090" Text="Time Missed 1hr 30mi"&gt;&lt;/asp:ListItem&gt;
                                    &lt;asp:ListItem Value="TM105" Text="Time Missed 1hr 45mi"&gt;&lt;/asp:ListItem&gt;
                                    &lt;asp:ListItem Value="TM120" Text="Time Missed 2hr"&gt;&lt;/asp:ListItem&gt;
                                    &lt;asp:ListItem Value="TM135" Text="Time Missed 2hr 15mi"&gt;&lt;/asp:ListItem&gt;
                                    &lt;asp:ListItem Value="TM150" Text="Time Missed 2hr 30mi"&gt;&lt;/asp:ListItem&gt;
                                    &lt;asp:ListItem Value="TM165" Text="Time Missed 2hr 45mi"&gt;&lt;/asp:ListItem&gt;
                                    &lt;asp:ListItem Value="TM180" Text="Time Missed 3hr"&gt;&lt;/asp:ListItem&gt;
                                    &lt;asp:ListItem Value="TM195" Text="Time Missed 3hr 15mi"&gt;&lt;/asp:ListItem&gt;
                                    &lt;asp:ListItem Value="TM210" Text="Time Missed 3hr 30mi"&gt;&lt;/asp:ListItem&gt;
                                    &lt;asp:ListItem Value="TM225" Text="Time Missed 3hr 45mi"&gt;&lt;/asp:ListItem&gt;
                                    &lt;asp:ListItem Value="TM240" Text="Time Missed 4hr"&gt;&lt;/asp:ListItem&gt;
                                    &lt;asp:ListItem Value="TM255" Text="Time Missed 4hr 15mi"&gt;&lt;/asp:ListItem&gt;
                                    &lt;asp:ListItem Value="TM310" Text="Time Missed 4hr 30mi"&gt;&lt;/asp:ListItem&gt;
                                    &lt;asp:ListItem Value="TM325" Text="Time Missed 4hr 45mi"&gt;&lt;/asp:ListItem&gt;
                                    &lt;asp:ListItem Value="WD" Text="Withdrawn"&gt;&lt;/asp:ListItem&gt;
                                &lt;/asp:DropDownList&gt;
                                &lt;asp:RequiredFieldValidator ID="AttendStatusValidator" runat="server"
                                    ErrorMessage="Required field" ControlToValidate="AttendStatusDropDownList"&gt;
                                &lt;/asp:RequiredFieldValidator&gt;
                            &lt;/td&gt;
                            &lt;td style="width: 200px"&gt;
                                &lt;asp:TextBox ID="CommentsTextBox" runat="server" TextMode="MultiLine" 
                                    Text='&lt;%# Eval("COMMENTS") %&gt;'&gt;&lt;/asp:TextBox&gt;
                            &lt;/td&gt;
                            &lt;td&gt;
&lt;%--                                &lt;asp:CheckBox ID="ChangeCheckBox" runat="server" Visible="true" /&gt;--%&gt;
                                &lt;asp:Label ID="PeopleCodeIdLabel" runat="server" Visible="false" Text='&lt;%# Eval("PEOPLE_CODE_ID") %&gt;'&gt;&lt;/asp:Label&gt;
                                &lt;asp:Label ID="AcademicYearLabel" runat="server" Visible="false" Text='&lt;%# Eval("ACADEMIC_YEAR") %&gt;'&gt;&lt;/asp:Label&gt;
                                &lt;asp:Label ID="AcademicTermLabel" runat="server" Visible="false" Text='&lt;%# Eval("ACADEMIC_TERM") %&gt;'&gt;&lt;/asp:Label&gt;
                                &lt;asp:Label ID="AcademicSessionLabel" runat="server" Visible="false" Text='&lt;%# Eval("ACADEMIC_SESSION") %&gt;'&gt;&lt;/asp:Label&gt;
                                &lt;asp:Label ID="EventIdLabel" runat="server" Visible="false" Text='&lt;%# Eval("EVENT_ID") %&gt;'&gt;&lt;/asp:Label&gt;
                                &lt;asp:Label ID="EventSubTypeLabel" runat="server" Visible="false" Text='&lt;%# Eval("EVENT_SUB_TYPE") %&gt;'&gt;&lt;/asp:Label&gt;
                                &lt;asp:Label ID="SectionLabel" runat="server" Visible="false" Text='&lt;%# Eval("SECTION") %&gt;'&gt;&lt;/asp:Label&gt;
                                &lt;asp:Label ID="TranAttendanceIdLabel" runat="server" Visible="false" Text='&lt;%# Eval("TranAttendanceId") %&gt;'&gt;&lt;/asp:Label&gt;
                            &lt;/td&gt;
                        &lt;/tr&gt;
                    &lt;/table&gt;
                    &lt;br /&gt;
                &lt;/ItemTemplate&gt;
            &lt;/asp:Repeater&gt;</code></pre>
</div>
</div>
</p>

<p>Code for the button: (Note the naming of the drop-downs. AttendanceStatusdropdownlist and AttendStatusAllDropDownList)</p>

<pre><code>    protected void ApplyToAllButton_Click(object sender, EventArgs e)
{
    string defaultStatus = AttendStatusAllDropDownList.SelectedValue;

    foreach (RepeaterItem item in AttendanceRepeater.Items)
    {
        DropDownList ddl = (DropDownList)item.FindControl("AttendanceStatusDropDownList");
        if (string.IsNullOrWhiteSpace(ddl.SelectedValue))
        {
            //set the ddl to the value selected from the other ddl
            ddl.SelectedValue = defaultStatus;

        }
    }
    //Save changes to all
    SaveButton_Click(null, null);
}
</code></pre>

<p>The values are not populating in the drop-downs inside the repeater. I have searched google but cannot find anything specific to what I'm attempting. Any help would be much appreciated.</p>

<p>Thanks in advance.
Pete</p>