title: DropDownList SelectedIndexChanged within Gridview not firing!
body: <p>I have been looking for a solution to this for a while though and seen many posts that show me how to do it but yet I cannot get my SelectedIndexChanged event to fire when the DropDownList is changed.</p>
  
  <p>The DropDownList AutoPostBack is set to True, i've followed code in the below post also:
  <a href="https://stackoverflow.com/questions/2109164/dropdownlist-selectedindexchanged-event-not-firing-within-gridview-headertemplate">Link to post</a></p>
  
  <p>Here is my code:</p>
  
  <p>.ASPX</p>
  
  <pre><code>    &lt;asp:GridView ID="gvCases" DataKeyNames="UserId" runat="server" AutoGenerateColumns="False" 
      BorderWidth="0px" CssClass="gridList" GridLines="None"&gt;
      &lt;AlternatingRowStyle BackColor="#F7F7F7" /&gt;
      &lt;Columns&gt;
  
          &lt;asp:BoundField DataField="id" HeaderText="Case Ref" /&gt;
  
          &lt;asp:TemplateField HeaderText="Name"&gt;
              &lt;ItemTemplate&gt;
                  &lt;asp:Label ID="clientName" runat="server" Text="Label"&gt;&lt;/asp:Label&gt;
              &lt;/ItemTemplate&gt;
          &lt;/asp:TemplateField&gt;
  
          &lt;asp:BoundField DataField="company" HeaderText="Company" /&gt;
  
          &lt;asp:TemplateField HeaderText="Order Date"&gt;
              &lt;ItemTemplate&gt;
                  &lt;asp:Label ID="dateTime" runat="server" Text="Label"&gt;&lt;/asp:Label&gt;
              &lt;/ItemTemplate&gt;
          &lt;/asp:TemplateField&gt;
  
          &lt;asp:TemplateField HeaderText="Case Owner"&gt;
              &lt;ItemTemplate&gt;
                  &lt;asp:DropDownList ID="iconUsers" runat="server" OnSelectedIndexChanged="iconUsers_SelectedIndexChanged"&gt;
                  &lt;/asp:DropDownList&gt;
              &lt;/ItemTemplate&gt;
          &lt;/asp:TemplateField&gt;
  
          &lt;asp:TemplateField ShowHeader="False"&gt;
              &lt;ItemTemplate&gt;
                  &lt;asp:Button ID="btnDetails" runat="server" CausesValidation="False" Text="Details" /&gt;
              &lt;/ItemTemplate&gt;
          &lt;/asp:TemplateField&gt;
  
          &lt;asp:TemplateField ShowHeader="False"&gt;
              &lt;ItemTemplate&gt;
                  &lt;asp:Button ID="btnSchedule" runat="server" CausesValidation="False" Text="Schedule" /&gt;
              &lt;/ItemTemplate&gt;
          &lt;/asp:TemplateField&gt;
  
  
  
      &lt;/Columns&gt;
  &lt;/asp:GridView&gt;
  </code></pre>
  
  <p>.VB</p>
  
  <pre><code>    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
  
  
      If (Request.IsAuthenticated = False) Then
          Response.Redirect("~/admin/default.aspx")
      End If
  
  
      Dim keypadSQL As SqlConnection = New SqlConnection()
      keypadSQL.ConnectionString = ConfigurationManager.ConnectionStrings("connKeypad").ConnectionString()
  
  
      Dim cmdActive As SqlCommand = New SqlCommand()
      cmdActive.Connection = keypadSQL
      cmdActive.CommandText = "spCasesActive"
      cmdActive.CommandType = CommandType.StoredProcedure
  
  
      Dim daCases As SqlDataAdapter = New SqlDataAdapter
      daCases.SelectCommand = cmdActive
  
      Dim dsCases As DataSet = New DataSet()
      daCases.Fill(dsCases, "CaseList")
  
      Dim CaseTotal As Integer
      CaseTotal = dsCases.Tables(0).Rows.Count
  
      If CaseTotal = 1 Then
          iCaseTotal.InnerHtml = CaseTotal &amp; " Case"
      Else
          iCaseTotal.InnerHtml = CaseTotal &amp; " Cases"
      End If
  
      gvCases.DataSource = dsCases
      gvCases.DataBind()
      cmdActive.Dispose()
  
  
      If Page.IsPostBack Then
  
      End If
  
  End Sub
  
  Protected Sub gvCases_RowDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles gvCases.RowDataBound
  
      If e.Row.RowType = DataControlRowType.Header Then
  
          gvCases.Columns(5).ItemStyle.Width() = "60"
          gvCases.Columns(6).ItemStyle.Width() = "70"
  
      End If
  
      If e.Row.RowType = DataControlRowType.DataRow Then
  
          Dim rowView As DataRowView = CType(e.Row.DataItem, DataRowView)
  
          Dim strClientName As String
          Dim clientName As Label
          strClientName = rowView("firstname") &amp; " " &amp; rowView("lastname")
          clientName = CType(e.Row.FindControl("clientName"), Label)
          clientName.Text = strClientName
  
          Dim strDateTime As String
          Dim dateTime As Label
          strDateTime = rowView("CaseSent")
          dateTime = CType(e.Row.FindControl("dateTime"), Label)
          dateTime.Text = FormatDateTime(strDateTime, DateFormat.ShortDate) &amp; "&lt;br /&gt;" &amp; FormatDateTime(strDateTime, DateFormat.ShortTime)
  
          gvCases.Columns(3).ItemStyle.Font.Size = 8
          gvCases.Columns(5).ControlStyle.CssClass = "btnEdit"
          gvCases.Columns(6).ControlStyle.CssClass = "btnSchedule"
  
          Dim intUserId As String
          intUserId = Convert.ToString(gvCases.DataKeys(e.Row.RowIndex).Value)
  
  
  
          Dim cmd As New SqlCommand("SELECT id, Firstname, Lastname, Firstname + ' ' + Lastname As FullName FROM [users_icon] ORDER BY Firstname, Lastname", New SqlConnection(ConfigurationManager.ConnectionStrings("connKeypad").ConnectionString()))
          cmd.Connection.Open()
  
          Dim ddlValues As SqlDataReader
          ddlValues = cmd.ExecuteReader()
  
          Dim iconUsers As DropDownList
          iconUsers = CType(e.Row.FindControl("iconUsers"), DropDownList)
          iconUsers.Style.Add("font-size", "11px")
          iconUsers.DataSource = ddlValues
          iconUsers.DataValueField = "id"
          iconUsers.DataTextField = "FullName"
          iconUsers.DataBind()
  
          Dim ListItem1 = New ListItem("Select Case Owner", "0")
          iconUsers.Items.Insert("0", ListItem1)
          iconUsers.AutoPostBack = True
          If IsDBNull(rowView("CaseOwner")) Then
              iconUsers.SelectedValue = 0
          Else
              iconUsers.SelectedValue = rowView("CaseOwner")
          End If
  
          AddHandler iconUsers.SelectedIndexChanged, AddressOf iconUsers_SelectedIndexChanged
  
          cmd.Connection.Close()
          cmd.Connection.Dispose()
  
  
          Dim btnDetails As Button = CType(e.Row.FindControl("btnDetails"), Button)
          btnDetails.PostBackUrl = "~/admin/detail.aspx?uid=" &amp; intUserId
  
          Dim LabelAddress As Button = CType(e.Row.FindControl("btnSchedule"), Button)
          LabelAddress.PostBackUrl = "~/admin/schedule.aspx?uid=" &amp; intUserId
  
      End If
  
  End Sub
  
  Protected Sub iconUsers_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs)
  
      Response.Write("Function Called")
  
  End Sub
  </code></pre>
  
  <p>Thanks for any help.
  J.</p>