Avinash Singh
Avinash Singh

Reputation: 2785

How to read a cell value a hidden colomn in WPF Datagrid

I am trying to read cell value of DataGrid hidden Column....

but its giving null value..

My code is

  FrameworkElement BId = dgFindBatch.Columns[1].GetCellContent(dgFindBatch.CurrentItem);
            int intBoardID = Convert.ToInt32(((TextBlock)BId));

How to get hidden column, cell value?

Upvotes: 0

Views: 835

Answers (1)

user1250709
user1250709

Reputation:

It may depends,

for example if every row is built of array of strings

You can easily try this

 string str = ((string[])dataGrid1.SelectedItem)[1];

 int intBoardID = 0;

 Int32.TryParse(str, out intBoardID);

But if there are other types you need to cast every one into its own type.

ps.

You cant do this

 Convert.ToInt32(((TextBlock)BId));

since BId was null it hasnt crashed.

Upvotes: 3

Related Questions