title: How to check if an object is a certain type
body: <p>I am passing various objects to a subroutine to run the same process but using a different object each time. For example, in one case I am using a ListView and in another case I am passing a DropDownList.</p>
  
  <p>I want to check if the object being passed is a DropDownList then execute some code if it is. How do I do this?</p>
  
  <p>My code so far which doesn't work:</p>
  
  <pre><code>Sub FillCategories(ByVal Obj As Object)
      Dim cmd As New SqlCommand("sp_Resources_Categories", Conn)
      cmd.CommandType = CommandType.StoredProcedure
      Obj.DataSource = cmd.ExecuteReader
      If Obj Is System.Web.UI.WebControls.DropDownList Then
  
      End If
      Obj.DataBind()
  End Sub
  </code></pre>