Hello,
I have a GridView defined as follows:
<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>
When a user clicks the edit button, I need to get the value of the BirthDate column. To attempt this, I have tried the following:
protected void myGridView_RowEditing(object sender, GridViewEditEventArgs e)
{
GridViewRow row = gvUsers.Rows[e.NewEditIndex];
DateTime birthDate = (DateTime)(row.Cells[1].Text);
// Does not work
}
I know it has something to do with the fact that the column is not visible. However, the column must be hidden. But, I need to get that value and I'm not sure how. Can someone please help? }