I'm having trouble getting the value of a cell in a DataGrid if that column is hidden. The following C# code works fine if the column is visible, but fails if it is hidden.
If the column is hidden, I get a null value exception because the visual elements haven't been created... the TextBlock is null. So the question is, how do I get the value from a hidden cell?
For the record, I use VS 2012, .NET 4.5, and program in C#.
I believe the VB version of this code would look like this:
Thanks in advance for any help on this.
Code:
int id = Convert.ToInt32(((TextBlock)grdData.Columns[0].GetCellContent(grdData.SelectedItem)).Text);
For the record, I use VS 2012, .NET 4.5, and program in C#.
I believe the VB version of this code would look like this:
Code:
Dim id As Integer = Convert.ToInt32(DirectCast(grdData.Columns(0).GetCellContent(grdData.SelectedItem), TextBlock).Text)