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

Update cell's text in RadGridView

6 Answers 770 Views
GridView
This is a migrated thread and some comments may be shown as answers.
flanky
Top achievements
Rank 1
flanky asked on 15 Jul 2010, 03:56 AM
I bind an entity to the RadGridView,then I update some cell's text  of gridview.
code like below:

radGridView.Rows[0].Cells[0].CellElement.Text = "Male";

But when gridview is refreshed(such as when I scroll the scrollbar of the gridview.), the cell's text I just set is gone instead of the value of the entity used to bind to the grdiview.
So how can I make cell's text keep unchanged ?

Thanks in advance,

6 Answers, 1 is accepted

Sort by
0
Svett
Telerik team
answered on 20 Jul 2010, 06:47 AM
Hello flanky,

This behavior is due to virtualization capabilities of the grid. You can read more about that in this documentation article. CellElement property of GridViewCellInfo class can be null if the cell is not visible in the currently presented area of the grid. If you want to change the text of concrete CellElement you should use CellFormatting event. You may refer to this help article.

Kind regards,
Svett
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
0
Accepted
Deiver
Top achievements
Rank 1
answered on 09 Jul 2012, 06:12 PM
I Had the same problem, but this code worked for me:

row.InvalidateRow();
0
Raminmjj
Top achievements
Rank 1
answered on 26 Apr 2016, 03:30 PM

Hi.

in below sample I need set Text property.

but "CellElement.Text" does not exist.

how can I do that?

foreach (GridViewRowInfo rowInfo in radGridView1.MasterTemplate.Rows)
{
    foreach (GridViewCellInfo cellInfo in rowInfo.Cells)
    {
        if (cellInfo.ColumnInfo.HeaderText == "Name")
        {
          cellInfo.CellElement.Text = "TestName";
        }
    }
}

0
Dess | Tech Support Engineer, Principal
Telerik team
answered on 27 Apr 2016, 11:36 AM
Hello Ramin,

Thank you for writing.

It is suitable to use the CellFormatting event in order to customize the text. Additional information is available here: http://docs.telerik.com/devtools/winforms/gridview/cells/formatting-cells

I hope this information helps. Should you have further questions I would be glad to help.

 Regards,
Dess
Telerik
Do you need help with upgrading your AJAX, WPF or WinForms project? Check the Telerik API Analyzer and share your thoughts.
0
Raminmjj
Top achievements
Rank 1
answered on 07 May 2016, 12:14 PM
Hello Dess,
Thank you for your answer.
But, "CellFormatting event" is not a good solution. some times we want to analyze a row in methods or functions, like a report generator.
please add Text property to CellInfo.

thank you.
0
Dess | Tech Support Engineer, Principal
Telerik team
answered on 10 May 2016, 08:20 AM
Hello Ramin,

Thank you for writing back. 

GridViewCellInfo represents the data cell which stores the relevant information. However, the GridCellElement represents the visual cell. RadGridView uses virtualization and cell elements are created only for currently visible cells and are being reused during operations like scrolling, filtering, grouping and so on. The CellFormatting event is explicitly introduced to handle customizing the visual cell elements and change their text.

Would it be possible to give us some more details about the specific case and why the CellFormatting event is not applicable to your case? Thus, we would be able to think about an alternative solution and assist you further.

I am looking forward to your reply.

Regards,
Dess
Telerik
Do you need help with upgrading your AJAX, WPF or WinForms project? Check the Telerik API Analyzer and share your thoughts.
Tags
GridView
Asked by
flanky
Top achievements
Rank 1
Answers by
Svett
Telerik team
Deiver
Top achievements
Rank 1
Raminmjj
Top achievements
Rank 1
Dess | Tech Support Engineer, Principal
Telerik team
Share this question
or