How to get the cell value in RowLoaded event ?

6 posts, 0 answers
  1. Bibhudutta
    Bibhudutta avatar
    11 posts
    Member since:
    Jan 2012

    Posted 02 Feb 2012 Link to this post

    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.
  2. Bibhudutta
    Bibhudutta avatar
    11 posts
    Member since:
    Jan 2012

    Posted 02 Feb 2012 Link to this post

    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. :)
  3. DevCraft banner
  4. Prabir
    Prabir avatar
    1 posts
    Member since:
    Mar 2011

    Posted 28 Mar 2012 Link to this post

    It did help someone :)

    Much appreciate your code sharing!
  5. Pavel Pavlov
    Admin
    Pavel Pavlov avatar
    2039 posts

    Posted 29 Mar 2012 Link to this post

    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 >>
  6. Anveshreddy
    Anveshreddy avatar
    2 posts
    Member since:
    May 2015

    Posted 07 Jul 2015 in reply to Pavel Pavlov Link to this post

    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.

     

  7. Dimitrina
    Admin
    Dimitrina avatar
    3769 posts

    Posted 09 Jul 2015 Link to this post

    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
Back to Top
DevCraft banner