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

[Solved] Buttons in a grid

1 Answer 122 Views
GridView
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Deepak Garla
Top achievements
Rank 1
Deepak Garla asked on 21 Oct 2009, 03:53 AM
Hi,
My grid has 2 buttons in 2 different columns.My requirements are on click of any button i should be able to change the properties of other  button  also.
Please help me out with this.

on button click event i can change the properties of only one button using (sender as button).content,but am not able to get the second button.


Regards,
Deepak Garla.

1 Answer, 1 is accepted

Sort by
0
Vlad
Telerik team
answered on 21 Oct 2009, 07:03 AM
Hi Deepak,

You can use our extension methods to get the job done easily:

XAML
        <telerikGrid:RadGridView>
            <telerikGrid:RadGridView.Columns>
                <telerikGrid:GridViewColumn>
                    <telerikGrid:GridViewColumn.CellTemplate>
                        <DataTemplate>
                            <Button Content="Button1" Click="Button1_Click"/>
                        </DataTemplate>
                    </telerikGrid:GridViewColumn.CellTemplate>
                </telerikGrid:GridViewColumn>
                <telerikGrid:GridViewColumn>
                    <telerikGrid:GridViewColumn.CellTemplate>
                        <DataTemplate>
                            <Button Content="Button2" Click="Button2_Click"/>
                        </DataTemplate>
                    </telerikGrid:GridViewColumn.CellTemplate>
                </telerikGrid:GridViewColumn> />
            </telerikGrid:RadGridView.Columns>
        </telerikGrid:RadGridView>

C#
        private void Button1_Click(object sender, RoutedEventArgs e)
        {
            var button2 = ((Button) sender).ParentOfType<GridViewRow>().ChildrenOfType<Button>().Where(b=>b.Content.Equals("Button2")).FirstOrDefault();
        }


Best wishes,
Vlad
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.
Tags
GridView
Asked by
Deepak Garla
Top achievements
Rank 1
Answers by
Vlad
Telerik team
Share this question
or