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

Clarification re DataItem population

1 Answer 32 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Mark H
Top achievements
Rank 1
Mark H asked on 08 Jul 2009, 05:58 PM
Just want to check that my understanding is correct from what I (think!) see happening...

1 - If I handle the _ItemDataBound event in a grid and set the DataItem.Text property, whatever I set there gets output and anything that would have been output had I not fielded the event is discarded

2 - If I handle the _ItemDataBound event in a grid and do something like DataItem.Controls.Add(...)  the rest of the controls have not yet been set and the content that would have been displayed using the DataItem.Text property is discarded

Not sure if I've explained that clearly enough but perhaps someone can point me at chapter and verse on exactly how one should edit/set/append values in grid cells at runtime in code?

Thanks, Mark

1 Answer, 1 is accepted

Sort by
0
Tsvetoslav
Telerik team
answered on 10 Jul 2009, 12:51 PM
Hello Mark H,

1.  Indeed, you are correct in your first observation, unless you use concatenation to attach additional text to the already existing one.

2. As for the second issue - the data item object represents a collection of  table cells and the value that gets into each table cell from the underlying data source is just plain text. So there are no controls being created by the grid to contain the text displayed apart from the table cells themselves. When you programmatically add controls to the table cell - its inner content (the text) gets overwritten.

I hope this information helps.

You can also find the following help article helpful in this regard: Accessing cells and rows.

Best regards,
Tsvetoslav
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
Tags
Grid
Asked by
Mark H
Top achievements
Rank 1
Answers by
Tsvetoslav
Telerik team
Share this question
or