This is a migrated thread and some comments may be shown as answers.

Retrieving row index of selected check box in grid view cell template.

5 Answers 404 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Kaustubh Wadi
Top achievements
Rank 1
Kaustubh Wadi asked on 20 Jul 2010, 08:10 AM
Hello Telerik Team,
    I have a RadGridview in my Silverlight application. Also I have a column having combo box as cell template. Here is the XAML code snippet for that.
<grid:RadGridView x:Name="gridview" Grid.Row="3" Grid.Column="0" Grid.ColumnSpan="4"  RowIndicatorVisibility="Collapsed" IsReadOnly="True" AutoGenerateColumns="False" CanUserFreezeColumns="False"  CanUserResizeColumns="False" Width="700">
             
           <grid:RadGridView.Columns>
               <grid:GridViewDataColumn x:Name="measuresCol"  Header="#" HeaderTextAlignment="Center"  Width="150" TextAlignment="Center" IsSortable="False"/>
                 
               <grid:GridViewDataColumn x:Name="cbG1"  Header="Header1" IsSortable="False" TextAlignment="Center" HeaderTextAlignment="Center">
                   <grid:GridViewDataColumn.CellTemplate>
                       <DataTemplate>
                           <CheckBox IsChecked="false" />
                       </DataTemplate>
                   </grid:GridViewDataColumn.CellTemplate>
               </grid:GridViewDataColumn>
</grid:RadGridView.Columns>
           </grid:RadGridView>

I want the row index of the check box which is checked by the user. Please can anyone suggest me the solution to achieve this?

Many Thanks,
Kaustubh.

5 Answers, 1 is accepted

Sort by
0
Veselin Vasilev
Telerik team
answered on 20 Jul 2010, 08:29 AM
Hello Kaustubh Wadi,

You can use the ParentOfType<> extension method to find the GridViewRow. Then you can get its DataContext which is your business object. Finally, you can use gridView.Items.IndexOf(the_business_object) to get the index.

Hope this will get you started.

All the best,
Veskoni
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Kaustubh Wadi
Top achievements
Rank 1
answered on 20 Jul 2010, 08:45 AM
Thanks Veskoni for your reply.
    Can you please explain it in little bit more detail for me? What should i exactly do?  I am very much new in Gridview.

Many Thanks,
Kaustubh.
0
Veselin Vasilev
Telerik team
answered on 20 Jul 2010, 09:03 AM
Hello Kaustubh Wadi,

First. let me know when do you want to get the index of the row? Is it on clicking the checkbox?

Sincerely yours,
Veskoni
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Kaustubh Wadi
Top achievements
Rank 1
answered on 20 Jul 2010, 09:11 AM
Hello Veskoni,
    Yes, when a user will click on the check box, I want the row index of that check box. For that I am using the clicked event of check box. But I am not getting how to retrieve the row index.

Many Thanks,
Kaustubh.
0
Veselin Vasilev
Telerik team
answered on 20 Jul 2010, 09:36 AM
Hello Kaustubh Wadi,

Find attached a sample project.

Best wishes,
Veskoni
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Tags
GridView
Asked by
Kaustubh Wadi
Top achievements
Rank 1
Answers by
Veselin Vasilev
Telerik team
Kaustubh Wadi
Top achievements
Rank 1
Share this question
or