我在我的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>
现在,当我从第 1 列获取值时,它为空:
TableCell rowData = tableResults.Rows[e.RowIndex].Cells[1];
oracleCom.CommandText = "Delete From TBL_VERSIONS Where i_id = " + rowData.Text;
如果我做了专栏visible = true
,我可以获得价值。但是这个列必须是不可见的。