title: DropDownList GridView Row wrong value
body: <p>I have a <code>GridView</code> which reads from a <code>SQLDataSource</code>. The data source has a select parameter that pulls from a <code>CheckBox</code>. When checked outdated records are shown.</p>
  
  <pre><code>&lt;asp:ControlParameter Name="showHidden" 
      ControlID="showHiddenEntries" 
      DbType="Boolean" 
      DefaultValue="0" 
      PropertyName="Checked" /&gt; 
  </code></pre>
  
  <p>I am playing with an idea to save space in a <code>GridView</code> on a narrow page and have replaced the standard controls with a <code>DropDownList</code>. In the DropDownLists <code>onSelectedIndexChanged</code> I set...</p>
  
  <pre><code>DropDownList controlList = (DropDownList)sender;
  GridViewRow row = (GridViewRow)controlList.NamingContainer;
  int RowIndex = row.RowIndex;
  string rowValue = gV.DataKeys[RowIndex].Value.ToString(); 
  </code></pre>
  
  <p>Then I have a switch statement for values of the <code>DropDownList</code>.</p>
  
  <p>Running my select query with hidden entries shown produces the ID's</p>
  
  <pre><code>650, 663, 675, 679, 648, 660, 680, 668, 657, 649
  </code></pre>
  
  <p>Entries 650 and 675 are "hidden". With the <code>showHiddenEntries</code> <code>CheckBox</code> checked the <code>GridView</code> displays the IDs I listed. When I select something from the <code>DropDownList</code> and loop through gV's data keys I see</p>
  
  <pre><code>663, 679, 648, 660, 680, 668, 657, 649, 645, 652
  </code></pre>
  
  <p>The <code>RowIndex</code> is right, but the <code>rowValue</code> is wrong. I checked with another project where I did something similar and it looks identical to me and functions perfectly. Can anyone point me in the right direction to fix this? </p>
  
  <p>Thanks! </p>
  
  <p>Toni W.</p>
  
  <p>Edit: I just realized I worded that a little poorly. The <code>RowIndex</code> is correct, but the entire row is wrong, not just the <code>rowValue</code>. If I have <code>showHiddenEntries</code> checked, in my GridView row 0 is <code>10, "Jane", "Doe", hidden</code> and row 1 is <code>15, "Misc", "Person", shown</code> and I select fromthe DropDownList in row 0 <code>RowIndex</code> evaluates to 0 and the data is <code>15, "Misc", "Person", shown</code>.</p>