First of all, I don't see you actually setting the row as Selected anywhere.
Up vote 0 down vote favorite share g+ share fb share tw.
I am using WPF Application Form with Telerik Gridview using C#. In that Gridview I inserted checkboxes using Data template. Its created but when I click or check the checkbox the current row is not getting selected.
How can I solve this problem? Please anyone tell me the solution of this problem. My xaml code for creating checkbox in grid is: In that checkbox I have created click event.
And also I want to know the current row number of the CheckBox Placed row in the gridview in checkbox click event. Give me some suggestion for this. Here My CheckBox Click event Code: private void CheckBox_Click(object sender, RoutedEventArgs e) { CheckBox selectedCheckbox = (CheckBox)sender; //this.
SelectedCasePackRadGrid -- This is my gridview // Here I want to get the selected row number } Thanks in Advance. C# wpf telerik link|improve this question edited Feb 10 at 13:16 asked Feb 10 at 11:18SuryaKavitha154.
1 Nowhere do I see you actually select the current row. – Zenexer Feb 10 at 11:42 I am not able to get current row of the gridview in CheckBox click event. Can you plese let me know how can I acheive this?
– SuryaKavitha Feb 10 at 11:57 I'm not entirely sure how this custom control works, but I'm assuming you can access it via the Parent property, at some level. – Zenexer Feb 10 at 12:06 please! Can you send the sample code for it?
Then only I can able to do that – SuryaKavitha Feb 10 at 13:13 Well, I'm not exactly sure how it would work; it's just a concept. – Zenexer Feb 10 at 13:15.
First of all, I don't see you actually setting the row as Selected anywhere. Your binding currently is setting a property in your DataContext called IsSelected. If this property actually exists, you can bind it to GridViewRow.
IsSelected in a style If it doesn't exist in your data object, you need to use a RelativeSource binding to find the GridViewRow and bind to it's IsSelected property Checked="{Binding RelativeSource={RelativeSource AncestorType={x:Type telerik:GridViewRow}}, Path=IsSelected}" As for finding the row number, there is no RowIndex property I know of that you can use to find the row number. One alternative is to get the GridView's ItemsSource and call IndexOf(dataobject), however that does break the separation of MVVM layers private void CheckBox_Click(object sender, RoutedEventArgs e) { CheckBox checkBox = (CheckBox)sender; var dataItem = checkBox. DataContext as MyDataItem; var parentDataObject = myGridView.
ItemsSource as SomeDataObject; if (dataItem == null || parentDataObject == null) return; var index = parentDataObject.SomeCollection. IndexOf(dataItem); // Do something with index } There are also other alternatives such as setting AlternationCount to something higher than the the number of rows, and accessing GridViewRow. AlternationIndex, although I don't know if that will work with Telerik's GridView But perhaps the best thing you could do is evaluate what you actually need the index for, and see if you can use some other alternative to accomplish what you want.
For example, if you want to pass the index of the selected row to a button command, it would be better to just pass the SelectedItem as the CommandParameter.
Rachel, Its Great. Now My gridview row is getting selected when checkbox checked by using your code. Thank you so much for your wonderful code.
Its very useful for me to do my work. Thank you Yar. :-) You are too great :-) – SuryaKavitha Feb 10 at 19:24.
I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.