title: get the value of each check marked check box inside rad grid in code behind
body: <p>In my radgrid I am using check box to select the required values from the multiple options. In my code behind, I want to get the value of every checked rows. But my loop is not working. </p>
  
  <p><em>Also I am not sure whether I am using the correct approach for the checkbox inside rad grid. Please suggest</em>.</p>
  
  <pre><code>&lt;telerik:RadGrid ID="rg_get_profession" runat="server"
  PageSize="100"
  AllowSorting="true"
  Width="100%"
  AllowPaging="True"
  ShowGroupPanel="false"
  AutoGenerateColumns="false"
  GridLines="Both"
  HeaderStyle-HorizontalAlign="Left" &gt;
  &lt;MasterTableView AutoGenerateColumns="false" AllowFilteringByColumn="false" ShowFooter="false"&gt;
      &lt;Columns&gt;
          &lt;telerik:GridTemplateColumn UniqueName="TempCol1" HeaderText="Select"&gt;
              &lt;ItemTemplate&gt;
                  &lt;asp:CheckBox ID="CheckBox1" runat="server" /&gt;
              &lt;/ItemTemplate&gt;
              &lt;EditItemTemplate&gt;
                  &lt;asp:CheckBox ID="CheckBox2" runat="server" /&gt;
              &lt;/EditItemTemplate&gt;
          &lt;/telerik:GridTemplateColumn&gt;
          &lt;telerik:GridBoundColumn DataField="p_id" Display="false" Visible="true" AutoPostBackOnFilter="false" CurrentFilterFunction="Contains" /&gt;
          &lt;telerik:GridBoundColumn DataField="p_name" HeaderText="Name" AutoPostBackOnFilter="false" CurrentFilterFunction="Contains" /&gt;     
      &lt;/Columns&gt;
  &lt;/MasterTableView&gt;
  &lt;/telerik:RadGrid&gt;
  </code></pre>
  
  <p>What I want to do is to insert the "<strong>p_id</strong>" for each checked rows in the database. But my loop is not working. Please suggest how can I achieve this. </p>
  
  <p>code behind >></p>
  
  <pre><code>foreach (GridDataItem item in rg_get_profession.Items)
  {
      CheckBox chkbox = item.FindControl("TempCol1") as CheckBox;
      if(chkbox != null &amp;&amp; chkbox.Checked)
      {
          string id = item.Cells[1].Text;
      }
  }
  </code></pre>
  
  <p>While debugging the code, the execution does not go inside the if block though I checked multiple items in the rad grid check box. 
  I tried doing ::</p>
  
  <pre><code>foreach (GridDataItem item in rg_get_profession.MasterTableView.Items)
      {
          CheckBox chkbox = item.FindControl("CheckBox1") as CheckBox;
          if (chkbox != null &amp;&amp; chkbox.Checked)
          {           
              string id_ = item.Cells[1].Text;            
          }
      }
  </code></pre>
  
  <p>Now when I put check mark in the check boxes, my execution goes inside the loop <code>if (chkbox != null &amp;&amp; chkbox.Checked)</code> but I can not access the value of <strong>p_id</strong>.
  <code>string id_ = item.Cells[1].Text;</code> is not giving the value of <strong>p_id</strong>. </p>
  
  <p>How can I access the value of p_id which are check marked? Please suggest.</p>