title: Unable to cast object of type 'System.Web.UI.WebControls.Button' to type 'System.Web.UI.WebControls.DropDownList'
body: <p>Error:</p>
  
  <blockquote>
    <p>Unable to cast object of type 'System.Web.UI.WebControls.Button' to type 'System.Web.UI.WebControls.DropDownList'</p>
  </blockquote>
  
  <p>Why?</p>
  
  <pre><code>&lt;EditFormSettings EditFormType="Template"&gt;
      &lt;FormTemplate&gt;
      &lt;asp:Label ID="Assign_t" runat="server" Font-Bold="True" ForeColor="#3366CC"&gt;Assign&lt;/asp:Label&gt;
  
      &lt;telerik:RadDropDownList ID="dd_Assign" runat="server" RenderMode="Lightweight" Skin="Bootstrap"  SelectedValue='&lt;%#Bind("Assign_to") %&gt;'&gt;
             &lt;Items&gt;
                &lt;telerik:DropDownListItem runat="server" Text="No Assign" Value="0" /&gt;
                &lt;telerik:DropDownListItem runat="server" Text="name1" Value="email1@svi.co.th" /&gt;
                &lt;telerik:DropDownListItem runat="server" Text="name2" Value="email2@svi.co.th" /&gt;
             &lt;/Items&gt;
      &lt;/telerik:RadDropDownList&gt;
  
      &lt;asp:Button ID="btnUpdate" Text='&lt;%# IIf((TypeOf (Container) Is GridEditFormInsertItem), "Insert", "Update") %&gt;' OnClick = "SendMail"
                                          runat="server" CommandName='&lt;%# IIf((TypeOf (Container) Is GridEditFormInsertItem), "PerformInsert", "Update")%&gt;' &gt;&lt;/asp:Button&gt;
      &lt;asp:Button ID="btnCancel" Text="Cancel" runat="server" CausesValidation="False"
                                              CommandName="Cancel"&gt;&lt;/asp:Button&gt;
      &lt;/FormTemplate&gt;
  &lt;/EditFormSettings&gt;
  </code></pre>
  
  
  
  <pre><code>Protected Sub SendMail(ByVal sender As Object, ByVal e As EventArgs)
  
      Dim ddlSection As DropDownList = DirectCast(sender, DropDownList)
      Dim editItem As GridEditFormItem = DirectCast(ddlSection.NamingContainer, GridEditFormItem)
      Dim dd_Assign As DropDownList = DirectCast(editItem.FindControl("dd_Assign"), DropDownList)
  
      Dim strFrom As String = "emailfrom@emailfrom.co.th" 
      Dim strCC As String = dd_Assign.SelectedItem.ToString
      Dim strBCC As String = "BCC@BCC.com" 'BCC
      Dim strSubject As String = "Request JOB Verification Approval" 
      Dim strBody As String = "test"
      Dim mailMessage As New System.Net.Mail.MailMessage(strFrom, strCC, strSubject, strBody)
      Dim mailClient As New System.Net.Mail.SmtpClient("xx.xx.xx.xx", 25)
      mailClient.Credentials = New System.Net.NetworkCredential("email@email.co.th", "pass") 
      mailClient.DeliveryMethod = Net.Mail.SmtpDeliveryMethod.Network
      mailClient.UseDefaultCredentials = True
      mailClient.Send(mailMessage)
  
  End Sub
  </code></pre>