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

literal control

4 Answers 374 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Ana
Top achievements
Rank 1
Ana asked on 23 Apr 2008, 08:44 AM
Hi, I have one probably very simple question, but I have to ask for help because of a lack of time.
Using literal controls in radgrid (something like 
RadGrid1.Controls.Add(new LiteralControl(string.Format("<span style='color:yellow;font-weight:bolder;'>{0}</span>", text)));),
how's it possible to place that literal control on the top instead of the bottom of the grid?
Thanks, Ana

4 Answers, 1 is accepted

Sort by
0
Iana Tsolova
Telerik team
answered on 23 Apr 2008, 02:08 PM
Hello Ana,

Try with the following code instead:

RadGrid1.Controls.AddAt(0,new LiteralControl(string.Format("<span style='color:yellow;font-weight:bolder;'>{0}</span>"text)));  
 

In this way, the literal control will be added as first on in the controls collection of the grid and will be displayed on top of it.

Best wishes,
Iana
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
Ana
Top achievements
Rank 1
answered on 24 Apr 2008, 07:30 AM
Thanks a lot. But to make this work, I had to set EnableViewState property to false. Why is that?
0
Iana Tsolova
Telerik team
answered on 24 Apr 2008, 01:59 PM
Hi Ana,

In fact this is not the best way of adding controls on top of RadGrid. Please excuse me for misleading you.

The items/controls collection of the grid is saved in a specific order in the ViewState, and after adding another control at first place in this collection, this order is being corrupted and the ViewState cannot be loaded.

If you want to display some text on top of RadGrid it is better to use the Caption property of the MasterTableView of the grid to assign your formatted string. Other option is to wrap the grid in another control and add the literal in it, before the grid.

Let me know if I can assist you further.

Best regards,
Iana
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
Ana
Top achievements
Rank 1
answered on 24 Apr 2008, 02:06 PM
Thanks for your answer! As I said, it's working fine now, or I still haven't made right move to detect error (if it exists). I will try with that Caption property, but I still don't have much time, so it's not priority at the moment. Thanks a lot. Ana
Tags
Grid
Asked by
Ana
Top achievements
Rank 1
Answers by
Iana Tsolova
Telerik team
Ana
Top achievements
Rank 1
Share this question
or