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

Question about RowLoaded event

1 Answer 32 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Jiaqi
Top achievements
Rank 1
Jiaqi asked on 03 Jul 2012, 11:38 AM
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!

1 Answer, 1 is accepted

Sort by
0
Dimitrina
Telerik team
answered on 03 Jul 2012, 01:39 PM
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 >>

Tags
GridView
Asked by
Jiaqi
Top achievements
Rank 1
Answers by
Dimitrina
Telerik team
Share this question
or