I did invisible first column in my gridview.:
<asp:GridView ID="tableResults" runat="server" DataMember="Table"
EnableModelValidation="True" CssClass = "GridViewStyle"
AutoGenerateColumns="False" OnRowDataBound = "tableResults_DataBound"
OnRowDeleting = "tableResults_RowDeleting" AutoGenerateDeleteButton="True">
<HeaderStyle CssClass = "GridViewHeaderStyle" />
<RowStyle CssClass = "GridViewRowStyle"/>
<Columns>
<asp:BoundField DataField="I_ID" Visible="false" HeaderText=""/>
<asp:BoundField DataField="I_MAJOR" HeaderText="Major"/>
<asp:BoundField DataField="I_MINOR" HeaderText="Minor"/>
<asp:BoundField DataField="I_RELEASE" HeaderText="Release"/>
<asp:BoundField DataField="I_BUILD" HeaderText="Build"/>
</Columns>
</asp:GridView>
Now when I get value from column 1 it null:
TableCell rowData = tableResults.Rows[e.RowIndex].Cells[1];
oracleCom.CommandText = "Delete From TBL_VERSIONS Where i_id = " + rowData.Text;
If i did column visible = true, i could get value. But this column must be invisible.
set DataKeyNames as I_ID
then you can get id as below
or you can set the cell invisible on gridview row data bound event, remove the invisible property on DataField=”I_ID”.