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

How to get the cell value in RowLoaded event ?

5 Answers 544 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Bibhudutta
Top achievements
Rank 1
Bibhudutta asked on 02 Feb 2012, 10:00 AM
I am trying to get a particular cell value for all rows in the RowLoaded event, but I am unable to get that.

        private void radGridView1_RowLoaded(object sender, RowLoadedEventArgs e)
        {
            if (e.Row is Telerik.Windows.Controls.GridView.GridViewRow)
            {
                if (e.DataElement != null)
                {
                    string phoneNumber = e.Row.Cells[12].ToString();
                }
            }
        }

But instead of giving the cell value, it's giving "Telerik.Windows.Controls.GridView.GridViewCell".

Please help me out.

5 Answers, 1 is accepted

Sort by
0
Bibhudutta
Top achievements
Rank 1
answered on 02 Feb 2012, 10:51 AM
At last, I got the solution.

        private void radGridView1_RowLoaded(object sender, RowLoadedEventArgs e)
        {
            if (e.Row is Telerik.Windows.Controls.GridView.GridViewRow)
            {
                if (e.DataElement != null)
                {
                    System.Windows.Controls.TextBlock textBlock = (TextBlock)e.Row.Cells[12].Content;
                    string phoneNumber = textBlock.Text;                   
                }
            }
        }

Hope it helps somebody. :)
0
Prabir
Top achievements
Rank 1
answered on 28 Mar 2012, 05:20 PM
It did help someone :)

Much appreciate your code sharing!
0
Pavel Pavlov
Telerik team
answered on 29 Mar 2012, 09:43 AM
Hello,

You may also  try using the Value property of the cell rather than the Content property.

All the best,
Pavel Pavlov
the Telerik team
Sharpen your .NET Ninja skills! Attend Q1 webinar week and get a chance to win a license! Book your seat now >>
0
Anveshreddy
Top achievements
Rank 1
answered on 07 Jul 2015, 06:01 PM

Pavlov,

 May be I am missing some references but I am not seeing Value property for Cell. I am using 2015 Q1 by the way. We don't have access to Text property of Content. I am not sure why it is so hard for Telerik to have a public property which can provide value of a cell. I have spent 2 hours searching to find this. I am binding my GridView with a ItemsSource, Columns are auto populated.

 

0
Dimitrina
Telerik team
answered on 09 Jul 2015, 07:04 AM
Hi,

Generally, we do not recommend working with the visual elements (i.e. GridViewCell) as RadGridView is a virtualized control and its elements are reused as they are brought in and out the view area. You can also check our online documentation explaining how the UI virtualization works. 

In order to access the values you can use RadGridView.Items collection and work with the bound data items and their properties directly.

Regards,
Dimitrina
Telerik
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 Feedback Portal and vote to affect the priority of the items
Tags
GridView
Asked by
Bibhudutta
Top achievements
Rank 1
Answers by
Bibhudutta
Top achievements
Rank 1
Prabir
Top achievements
Rank 1
Pavel Pavlov
Telerik team
Anveshreddy
Top achievements
Rank 1
Dimitrina
Telerik team
Share this question
or