我定義了一個GridView
如下:獲取隱藏字段值
<asp:GridView ID="myGridView" AutoGenerateColumns="false" runat="server"
OnLoad="myGridView_Load" OnRowCommand="myGridView_Command" OnRowEditing="myGridView_RowEditing" OnRowDeleting="myGridView_RowDeleting" DataKeyNames="ID" >
<Columns>
<asp:BoundField DataField="ID" Visible="false" />
<asp:BoundField DataField="BirthDate" Visible="false" />
<asp:BoundField DataField="FirstName" HeaderText="First Name" />
<asp:BoundField DataField="LastName" HeaderText="Last Name" />
<asp:TemplateField HeaderText="Other">
<ItemTemplate>
<asp:LinkButton ID="editLB" runat="server" Text="edit" CommandName="Edit" />
<asp:LinkButton ID="deleteLB" runat="server" Text="delete" CommandName="Delete" />
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
當用戶點擊編輯按鈕,我需要得到BirthDate
列的值。要嘗試此操作,我嘗試了以下操作:
protected void myGridView_RowEditing(object sender, GridViewEditEventArgs e)
{
GridViewRow row = gvUsers.Rows[e.NewEditIndex];
DateTime birthDate = (DateTime)(row.Cells[1].Text);
// Does not work
}
我知道它與列不可見的事實有關。該列必須隱藏。但我需要得到那個價值—我該怎麼做?
我想第二個,但它只是牆根價值觀和頭部仍然存在。我怎麼能隱藏標題? (我不能使用visible = false,因爲我需要它的數據) – Rapunzo 2012-05-09 15:21:09
設置頭css類隱藏 – MattBH 2015-06-26 08:51:34