3 Answers, 1 is accepted
There are several ways to get a cell value. For example you could do something like that:
var firstRow = this.gridView.ItemContainerGenerator.ContainerFromIndex(0) as GridViewRow; var firstCell = firstRow.Cells[0] as GridViewCell; var value = firstCell.Value;I am not exactly sure if I have understood the second question. Could you elaborate a bit?
All the best,
Milan
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
There is a CheckBox in CellTemplate of GridView .
I want to get the value of the CheckBox in the whole column one by one .
So that I can judge whether there is any checked CheckBox.
Thank you all !
By default RadGridView uses virtualization to boos performance and only the visible rows are available - it is not possible to get visual elements that are not visible.
If the checkboxes are bound to a property of your data items it is best to loop through the data items instead of the visual elements. For example:
foreach(MyDataItemType dataItem in this.myGridView.Items) { // checking the property that is bound to a checkbox if(dataItem.IsChecked) { // do something } }Another approach is to turn off the vertical virtualization by setting EnableRowVirtualization to false which will create all visual elements but decrease performance.
If you turn of the virtualization you will be able to do something like that:
foreach(var dataItem in this.myGridView.Items) { var firstRow = this.gridView.ItemContainerGenerator.ContainerFromItem(dataItem) as GridViewRow; var checkBoxCell = firstRow.Cells[0] as GridViewCell; var checkBox = checkBoxCell.ChildrenOfType<CheckBox>().FirstOrDefault() }In my opinion te first approach is the preferred way.
Kind regards,Milan
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.