How to get ID from the GridView in GridView_RowDeleting event using C#?
<p>I want to delete one particular row in Gridview. So I need ID, How can I get the ID of the row in GridView_RowDeleting Event?</p>

<p>Here is the column list of the GridView,</p>

<pre><code>&lt;Columns&gt;
  &lt;asp:TemplateField HeaderText="S.No." ControlStyle-Width="100%" ItemStyle-Width="30px"&gt;
    &lt;ItemTemplate&gt;
      &lt;asp:Label ID="lblSrno" runat="server" Text=''
        &lt;%# Container.DataItemIndex + 1 %&gt;'&gt;&lt;/asp:Label&gt;
    &lt;/ItemTemplate&gt;
    &lt;ControlStyle Width="100%" /&gt;
    &lt;ItemStyle Width="30px" /&gt;
  &lt;/asp:TemplateField&gt;
  &lt;asp:TemplateField Visible="false"&gt;
    &lt;ItemTemplate&gt;
      &lt;asp:Label runat="server" ID="lblDrawingID" Text=''
        &lt;%# Bind("DrawingID")%&gt;'&gt;&lt;/asp:Label&gt;
    &lt;/ItemTemplate&gt;
  &lt;/asp:TemplateField&gt;
  &lt;asp:BoundField DataField="CustDrawingNbr" HeaderText="Customer Drawing No." /&gt;
  &lt;asp:TemplateField HeaderText="Status" ControlStyle-Width="100px" ItemStyle-Width="100px"&gt;
    &lt;ItemTemplate&gt;
      &lt;asp:DropDownList ID="ddlStatus" runat="server" Width="100px" Enabled="false"&gt;
      &lt;/asp:DropDownList&gt;
    &lt;/ItemTemplate&gt;
    &lt;ControlStyle Width="100px" /&gt;
    &lt;ItemStyle Width="100px" /&gt;
  &lt;/asp:TemplateField&gt;

  &lt;asp:TemplateField Visible="false"&gt;
    &lt;ItemTemplate&gt;
      &lt;asp:Label runat="server" ID="lblDrawingPGMAStatusID" Text=''
        &lt;%# Bind("StatusID")%&gt;'&gt;&lt;/asp:Label&gt;
    &lt;/ItemTemplate&gt;
  &lt;/asp:TemplateField&gt;
  &lt;asp:TemplateField Visible="false"&gt;
    &lt;ItemTemplate&gt;
      &lt;asp:Label runat="server" ID="lblDrawingPGMAID" Text=''
        &lt;%# Bind("PGMAID")%&gt;'&gt;&lt;/asp:Label&gt;
    &lt;/ItemTemplate&gt;
  &lt;/asp:TemplateField&gt;
  &lt;asp:CommandField ShowDeleteButton="true" HeaderText="Action" ItemStyle-HorizontalAlign="Center"
      ItemStyle-VerticalAlign="Middle"&gt;
    &lt;ItemStyle HorizontalAlign="Center" VerticalAlign="Middle" /&gt;
  &lt;/asp:CommandField&gt;
&lt;/Columns&gt;
</code></pre>

<p>Here I fill one datatable with this GridView.
The DataTable Columns are DrawingID, CustDrawingNbr, JobOrderID, StatusID, PGMAID, SeqNo.
So I want to get the DrawingID when I click the Delete button.</p>

<p>So far,
        I have tried the following things. But nothing has given the desired result.</p>

<ol>
<li><p>Label lblDraw = (Label)gvApplicablePGMASearch.Rows[e.RowIndex].Cells[2].FindControl("lblDrawingID");
int drawid = Convert.ToInt32(lblDraw.Text);</p></li>
<li><p>string drawid = gvApplicablePGMASearch.DataKeys[e.RowIndex].Value.ToString();</p></li>
<li>string id = gvApplicablePGMASearch.SelectedDataKey.Value.ToString();</li>
</ol>

<p>But none of the above has not given the desired result.</p>
