Hi
I am using C#, ASP.NET 3.5, Visual Studio 2008 and Prometheus Q3 SP1.
I need to add a HTML message to my footer in my RadGrid.
I tried the following:
'TableRow' cannot have children of type 'LiteralControl'.
Basically what I'm trying to achieve is a custom HTML message just above the Page Index row.
Kind regards
Mark Eaton
I am using C#, ASP.NET 3.5, Visual Studio 2008 and Prometheus Q3 SP1.
I need to add a HTML message to my footer in my RadGrid.
I tried the following:
protected void RadGrid1_ItemCreated(object source, Telerik.Web.UI.GridItemEventArgs e)
{
if (e.Item.ItemType == GridItemType.Footer)
{
GridFooterItem footer = e.Item as GridFooterItem;
footer.Controls.Add(new LiteralControl("Hello World!"));
}
}
'TableRow' cannot have children of type 'LiteralControl'.
Basically what I'm trying to achieve is a custom HTML message just above the Page Index row.
Kind regards
Mark Eaton
6 Answers, 1 is accepted
0
Hello Mark,
You can add this literal directly in the grid controls collection.
All the best,
Vlad
the Telerik team
Instantly find answers to your questions at the new Telerik Support Center
You can add this literal directly in the grid controls collection.
All the best,
Vlad
the Telerik team
Instantly find answers to your questions at the new Telerik Support Center
0
Mark
Top achievements
Rank 1
answered on 25 Feb 2008, 10:30 PM
Hi Vlad
I'm not sure I understand what you mean. I tried the following:
GridFooterItem footer = RadGrid1.MasterTableView.GetItems(GridItemType.Footer)[0] as GridFooterItem;
footer.Controls.Add(new LiteralControl("Hello World!"));
... but I got the same error as before.
Remember, as stated previously, I need this in the footer (which is above the Page Index) and not below it at the bottom of the grid.
Can you also please provide me a working code example.
Kind regards
Mark Eaton
I'm not sure I understand what you mean. I tried the following:
GridFooterItem footer = RadGrid1.MasterTableView.GetItems(GridItemType.Footer)[0] as GridFooterItem;
footer.Controls.Add(new LiteralControl("Hello World!"));
... but I got the same error as before.
Remember, as stated previously, I need this in the footer (which is above the Page Index) and not below it at the bottom of the grid.
Can you also please provide me a working code example.
Kind regards
Mark Eaton
0
Hello Mark,
Can you try with this code:
This will add the literal in the footer of the column with UniqueName MyColumnUniqueName. More on how to access cells and rows of the Grid find here:
http://www.telerik.com/help/radcontrols/prometheus/?grdaccessingcellsandrows.html
Regards,
Iana
the Telerik team
Instantly find answers to your questions at the new Telerik Support Center
Can you try with this code:
| protected void RadGrid1_ItemCreated(object sender, Telerik.WebControls.GridItemEventArgs e) |
| { |
| if (e.Item is GridFooterItem) |
| { |
| Literal literal = new Literal(); |
| literal.Text = "Hello World!"; |
| e.Item["MyColumnUniqueName"].Controls.Add(literal); |
| } |
| } |
This will add the literal in the footer of the column with UniqueName MyColumnUniqueName. More on how to access cells and rows of the Grid find here:
http://www.telerik.com/help/radcontrols/prometheus/?grdaccessingcellsandrows.html
Regards,
Iana
the Telerik team
Instantly find answers to your questions at the new Telerik Support Center
0
Mark
Top achievements
Rank 1
answered on 26 Feb 2008, 10:35 PM
Hi Iana
Thanks for the response. The code example works well, however what I really want may not be possible?
I want this text to stretch across the length of the grid and not restricted to just one column.
For example:
RadGrid1.Controls.Add(new LiteralControl("Hello World"));
This is not resticted to any one column but stretches across the length of the grid.
Is such a thing possible for the footer?
Kind regards
Mark Eaton
0
Hi Mark,
Thank your for your detailed explanation.
It is possible to stretch your footer across the whole Grid. You need to remove the unnecessary cells of the footer, leave only one then colspan it so it's under all columns. I've prepared a sample for you. Try it and tell us if that helps.
Greetings,
Iana
the Telerik team
Instantly find answers to your questions at the new Telerik Support Center
Thank your for your detailed explanation.
It is possible to stretch your footer across the whole Grid. You need to remove the unnecessary cells of the footer, leave only one then colspan it so it's under all columns. I've prepared a sample for you. Try it and tell us if that helps.
Greetings,
Iana
the Telerik team
Instantly find answers to your questions at the new Telerik Support Center
0
Mark
Top achievements
Rank 1
answered on 29 Feb 2008, 02:19 AM
Hi Iana
That works very well.
Kind regards
Mark Eaton
That works very well.
Kind regards
Mark Eaton
