void Item_Bound(Object sender, DataGridItemEventArgs e)
{
HtmlInputHidden hdnID = dgItem.Cells[0].FindControl("hdnID") as HtmlInputHidden;
if (hdnID!=null)
{
int intID = Convert.ToInt32(hdnID.Value); //This way if the control is not found for any reason the application will not blow up exposing your logic
}
}
Private Sub Item_Bound(ByVal sender As [Object], ByVal e As DataGridItemEventArgs)
Dim hdnID As HtmlInputHidden = TryCast(dgItem.Cells(0).FindControl("hdnID"), HtmlInputHidden)
If hdnID IsNot Nothing Then
'This way if the control is not found for any reason the application will not blow up exposing your logic
Dim intID As Integer = Convert.ToInt32(hdnID.Value)
End If
End Sub
https://www.experts-exchange.com/questions/23012008/Hidden-field-in-a-datagrid.html