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

How to get a current row's information of dynimic button in gridview

1 Answer 77 Views
GridView
This is a migrated thread and some comments may be shown as answers.
KYUNG RYEOL CHA
Top achievements
Rank 1
KYUNG RYEOL CHA asked on 30 May 2010, 11:31 PM
    public class MyGridViewDataColumn : GridViewDataColumn  
    {  
 
        public override FrameworkElement CreateCellElement(GridViewCell cell, object dataItem)  
        {  
            Button btn = new Button();  
            btn.Width = 30;  
            btn.Content = "Click";  
            btn.Click += new RoutedEventHandler(btn_Click);  
            return btn;  
        }  
 
        void btn_Click(object sender, RoutedEventArgs e)  
        {  
            Control ctrl = sender as Control;  
            if (ctrl != null)  
            {  
                ctrl.Focus();  
            }  
              
            MessageBox.Show( ???? <- i wanna get a value of this row's another cell );  
            //throw new NotImplementedException();  
        }  
    } 

Hi.

Sorry for taking your time. but i can't search a solution of my problem.
I saw some code for making a dynimic button in gridview.
but i cant get a value of another cell in the button's row Or rowindex of the clicked button.
how to get the infomation?

thank you advance.

1 Answer, 1 is accepted

Sort by
0
Vlad
Telerik team
answered on 31 May 2010, 07:25 AM
Hello,

If you cast ctrl.DataContext to your object type you can get any property in this event.

Regards,
Vlad
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
KYUNG RYEOL CHA
Top achievements
Rank 1
Answers by
Vlad
Telerik team
Share this question
or