title: Get Value of ListView Item on selectedIndexChanged on Dropdownlist in ListView
body: <p>I have a ListView and DropDownList in every Row of that ListView. You can cahnge a assigned person in that DropDownlist (the DropDownList shows Data from a MySql Database). </p>
  
  <p>When changing the person I need to do some database operation. For that I need to know on which ListView Row the person was changed and I need to know the value of the entry.</p>
  
  <p>Here is my aspx-file: </p>
  
  <pre><code>&lt;asp:ListView ID="manageAssigneesListView" runat="server" DataKeyNames="" OnItemDataBound="OnDataBound"&gt;            
                  &lt;ItemTemplate&gt;
                      &lt;div class="summaryRow"&gt;
                          &lt;asp:Label ID="customerId" runat="server"&gt;&lt;%# Eval("customerId") %&gt;&amp;nbsp;&lt;/asp:Label&gt;    
                          &lt;div style="width:200px; margin: 0px 5px; float: left;"&gt;&lt;%# Eval("lastName") %&gt;, &lt;%# Eval("firstName") %&gt;&lt;/div&gt;
                          &lt;div style="width:120px; margin: 0px 2px; float: left;"&gt;Nr.&lt;/div&gt;
                          &lt;div style="width:200px; margin-left: 50px; float: right;"&gt;
                              &lt;asp:DropDownList runat="server" ID="selectAssignee" Width="196" AppendDataBoundItems="true" OnSelectedIndexChanged="selectAssignee_OnSelectedIndexChanged" AutoPostBack="true"&gt;
                              &lt;/asp:DropDownList&gt;
                          &lt;/div&gt;
                          &lt;div class="clear"&gt;&lt;/div&gt;
                      &lt;/div&gt;
                  &lt;/ItemTemplate&gt;
              &lt;/asp:ListView&gt;   
  </code></pre>
  
  <p>Here is my codebehind:</p>
  
  <pre><code>protected void Page_Load(object sender, EventArgs e)
      {
          Helper.doAuth(Session, Response);
  
          if (!IsPostBack)
          {
              // load all customers without assignee
              MySqlCommand cmd = new MySqlCommand();
              MySqlConnection con = new MySqlConnection();
              con.ConnectionString = Helper.CONNECTION_STRING;
              cmd.CommandText = "SELECT customerId, lastName, firstName, assignee FROM customer WHERE assignee IS NULL ORDER BY customerId DESC";
              cmd.Connection = con;
              con.Open();
              MySqlDataAdapter sda = new MySqlDataAdapter(cmd);
              DataSet ds = new DataSet();
              sda.Fill(ds);
              manageAssigneesListView.DataSource = ds;
              manageAssigneesListView.DataBind();
              con.Close();
  
          }
      }
  
      protected void OnDataBound(object sender, ListViewItemEventArgs e)
      {
          DropDownList selectAssignee = (e.Item.FindControl("selectAssignee") as DropDownList);
  
          MySqlCommand cmd = new MySqlCommand();
          MySqlConnection con = new MySqlConnection();
          con.ConnectionString = Helper.CONNECTION_STRING;
          cmd.CommandText = "SELECT * FROM user where role = " + Helper.ROLE_SALESPERSON;
          cmd.Connection = con;
          con.Open();
          MySqlDataAdapter sda = new MySqlDataAdapter(cmd);
          DataSet ds = new DataSet();
          sda.Fill(ds);
          selectAssignee.DataSource = ds;
          selectAssignee.DataTextField = "emailAdress";
          selectAssignee.DataBind();
          con.Close();    
      }
  
  
      protected void selectAssignee_OnSelectedIndexChanged(object sender, EventArgs e)
      {
          DropDownList dropDownList = (DropDownList)sender;
          ListViewItem listView = (ListViewItem)dropDownList.NamingContainer;
  
          var test = listView.DataItem;
          string test2 = listView.FindControl("customerId").ToString();
  
          int rowIndex = (int)listView.DataItemIndex;
          Label lblMessage = (Label)listView.FindControl("customerId");
      }
  </code></pre>
  
  <p>I was successful getting the DataItemIndex of the Row I changed the value of the DropDownList, also the DropDownlist is firing correcty onSelectedIndexChanged, but what I need is the value of the Label "customerId" and I don't know how to get this value.</p>
  
  <p>Thanks in advance</p>