Question about RowLoaded event

2 posts, 0 answers
  1. Jiaqi
    Jiaqi avatar
    6 posts
    Member since:
    Nov 2011

    Posted 03 Jul 2012 Link to this post

    Hello.

    I have a question about rowloaded event.

    I generate column of gridview by code as follow:
    void GenerateGridView()
    {
    for (int i=0;i<30;i++)
    {
                 GridViewDataColumn column = new GridViewDataColumn();
                    column.Header = i.ToString();
                     column.IsReadOnly = true;
                     this.gridview1.Columns.Add(column);
    }
    this.gridview1.ItemSource = list;//my data
    }
      
      
       private void gridview1_RowLoaded(object sender, RowLoadedEventArgs e)
     {
                   if (e.Row is GridViewHeaderRow)
                               return;
                    for(int j=0;j<30;j++)
                            e.Row.Cells[j].Content = j.ToString()
      }

    but in RowLoaded event , if  j>18,it will error, i runing it step by step the e.Row.cells.count is 18. why?

    Thanks in advance!
  2. Dimitrina
    Admin
    Dimitrina avatar
    3769 posts

    Posted 03 Jul 2012 Link to this post

    Hello,

     The RadGridView supports UI Virtualization as explained in this help article. Since the virtualization is turned on by default, it is not recommended to work with the visual elements (i.e. Rows and Cells) and their properties. 

    I would recommend you to populate the values by exposing a new property and binding the column to that property.

    Greetings,
    Didie
    the Telerik team

    Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

Back to Top