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

Insert image in header of detail table

2 Answers 47 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Kevin
Top achievements
Rank 1
Kevin asked on 25 Sep 2008, 07:26 AM
Is there any way to insert an image into the header of a detail table. I tried to use ItemCreated to insert the image, however I have set HierarchyLoadMode="ServerOnDemand" which means that the ItemCreated doesn't fire when the detail table is created? Is there anything similar to ItemCreated that I can access to do this when the detail table is created?

thanks

Kevin

2 Answers, 1 is accepted

Sort by
0
Accepted
Princy
Top achievements
Rank 2
answered on 25 Sep 2008, 09:13 AM
Hello Kevin,

I tried the following code snippet to insert an image in the header of  the detail table and it worked fine in ItemCreated as well as ItemDataBound.You need to add the expanded property of the grid.
cs:
   protected void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e) 
    { 
       foreach (GridDataItem item in RadGrid1.Items) 
        { 
            if (item.Expanded) 
            { 
                GridTableView nestedView = ((GridDataItem)item).ChildItem.NestedTableViews[0]; 
                foreach (GridHeaderItem headerItem in nestedView.GetItems(GridItemType.Header)) 
                { 
                    Image img = new Image(); 
                    img.ID = "Image1"
                    img.ImageUrl = "~/images/New Image.gif"
                    headerItem["Name"].Controls.Clear(); 
                    headerItem["Name"].Controls.Add(img); 
                }                 
            } 
        } 
    } 
 
 

Thanks
Princy.
0
Kevin
Top achievements
Rank 1
answered on 25 Sep 2008, 10:47 PM
Works like a charm - thanks
Tags
Grid
Asked by
Kevin
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Kevin
Top achievements
Rank 1
Share this question
or