Quantcast
Channel: VBForums - WPF, WCF, WF
Viewing all articles
Browse latest Browse all 256

[RESOLVED] How get the value of a HIDDEN DataGrid cell?

$
0
0
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.

Code:

int id = Convert.ToInt32(((TextBlock)grdData.Columns[0].GetCellContent(grdData.SelectedItem)).Text);
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:

Code:

Dim id As Integer = Convert.ToInt32(DirectCast(grdData.Columns(0).GetCellContent(grdData.SelectedItem), TextBlock).Text)
Thanks in advance for any help on this.

Viewing all articles
Browse latest Browse all 256

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>