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

RadGrid Not Displaying In Inherited Webpart

1 Answer 19 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Samuel Webb
Top achievements
Rank 1
Samuel Webb asked on 09 Oct 2008, 04:04 PM
Greetings,

I have a strange situation. I have a Sharepoint web part which works wonderfully using the Telerik RadGrid to display data. I now want to create an similar webpart with Ajax functionality. My first thought was to build this second part like this (code paraphrased):

[C#]
public class AjaxMetricGridWebPart : MetricGridWebPart
{
public override CreateChildControls()
{
// Allow the parent class to do its work
base.CreateChildControls();

// Find the grid in the control collection and remove it
Control rg;
foreach (Control c in this.Controls)
{
if (c is RadGrid)
{
rg = c;
break;
}
}

this.Controls.Remove(rg);

// Create an ASP.NET UpdatePanel
UpdatePanel up = new UpdatePanel();
up.ContentTemplateContainer.Controls.Add(rg);

this.Controls.Add(up);
}
}
When I do this, the grid does not display in the new web part. However, copying the code from the MetricGridWebPart class into the AjaxMetricGridWebPart class and simply modifying the CreateChildControls() method works great.

I would rather not manage the same code in two places. It seems that what I'm trying to do in the first example should work just fine. Is there some subtlety in the RadGrid that stops it from being displayed when it is moved from one ControlCollection to another?

.NET 3.0, Sharepoint 2007

1 Answer, 1 is accepted

Sort by
0
Rosen
Telerik team
answered on 14 Oct 2008, 12:28 PM
Hello Samuel,

I'm afraid that I'm unable to recreate the behavior which you have described. I have attached a small video which captures the WebParts' behavior on my machine. Please take a look and let me know if I'm missing something obvious.

All the best,
Rosen
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Tags
Grid
Asked by
Samuel Webb
Top achievements
Rank 1
Answers by
Rosen
Telerik team
Share this question
or