title: How to find the data key on CheckedChanged event of checkbox in ListView in ASP.NET?
body: <p>I am using a list view inside that in item template i am using a label and a checkbox.
  I want that whenever user clicks on the check box the value should be updated in a table.i am using a datakeys in listview.on the basis of datakey value should be updated in the table. Query is:</p>
  
  <pre><code>string updateQuery = "UPDATE [TABLE] SET [COLUMN] = " + Convert.ToInt32(chk.Checked) + " WHERE PK_ID =" + dataKey + " ";` 
  </code></pre>
  
  <p>also i want some help in displaying the result as it is inside the table.means if the value for column in table for a particular pkid is 1 then the checkbox shoul be checked.</p>
  
  <p>Here is the code snippet:</p>
  
  <pre><code>&lt;asp:ListView ID="lvFocusArea" runat="server" DataKeyNames="PK_ID" OnItemDataBound="lvFocusArea_ItemDataBound"&gt;
      &lt;LayoutTemplate&gt;
          &lt;table border="0" cellpadding="1" width="400px"&gt;
              &lt;tr style="background-color: #E5E5FE"&gt;
                  &lt;th align="left"&gt;
                      Focus Area
                  &lt;/th&gt;
                  &lt;th&gt;
                      Is Current Focused
                  &lt;/th&gt;
              &lt;/tr&gt;
              &lt;tr id="itemPlaceholder" runat="server"&gt;
              &lt;/tr&gt;
          &lt;/table&gt;
      &lt;/LayoutTemplate&gt;
      &lt;ItemTemplate&gt;
          &lt;tr&gt;
              &lt;td width="80%"&gt;
                  &lt;asp:Label ID="lblFocusArea" runat="server" Text=""&gt;&lt;%#Eval("FOCUS_AREA_NAME") %&gt;&lt;/asp:Label&gt;
              &lt;/td&gt;
              &lt;td align="center" width="20%"&gt;
                  &lt;asp:CheckBox ID="chkFocusArea" runat="server" OnCheckedChanged="chkFocusArea_CheckedChanged" AutoPostBack="true" /&gt;
              &lt;/td&gt;
          &lt;/tr&gt;
      &lt;/ItemTemplate&gt;
      &lt;AlternatingItemTemplate&gt;
          &lt;tr style="background-color: #EFEFEF"&gt;
              &lt;td&gt;
                  &lt;asp:Label ID="lblFocusArea" runat="server" Text=""&gt;&lt;%#Eval("FOCUS_AREA_NAME") %&gt;&lt;/asp:Label&gt;
              &lt;/td&gt;
              &lt;td align="center"&gt;
                  &lt;asp:CheckBox ID="chkFocusArea" runat="server" OnCheckedChanged="chkFocusArea_CheckedChanged" AutoPostBack="true" /&gt;
              &lt;/td&gt;
          &lt;/tr&gt;
      &lt;/AlternatingItemTemplate&gt;
      &lt;SelectedItemTemplate&gt;
          &lt;td&gt;
              item selected
          &lt;/td&gt;
      &lt;/SelectedItemTemplate&gt;
  &lt;/asp:ListView&gt;
  </code></pre>
  
  <p>Help me.</p>