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

[Solved] Add controls to a group column cell

2 Answers 76 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Jake
Top achievements
Rank 1
Jake asked on 17 Sep 2009, 09:16 PM
Is it possible to add controls (e.g. an Image) to a cell in the rgGroupCol column?

To illustrate:

In the following diagram, x is the collapse/expand link, and o is the location that I want to insert an image. The image displayed would be dependent on an item of data from its corresponding row.

-------------------------------------
     | Column1 | Column 2 |
-------------------------------------
x    -- Group 1 Header Row --
-------------------------------------
o    |              |                 |
-------------------------------------
o    |              |                 |
-------------------------------------
x    -- Group 2 Header Row --
-------------------------------------
o    |              |                 |
-------------------------------------
...

Thanks!

2 Answers, 1 is accepted

Sort by
0
Accepted
Shinu
Top achievements
Rank 2
answered on 18 Sep 2009, 05:01 AM
Hi Jake,

Give a try with the following code snippet and see whether it works.

CS:
 
 protected void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e) 
    { 
        if (e.Item is GridDataItem) 
        { 
            GridDataItem item = (GridDataItem)e.Item; 
 
            //create the image 
            Image img = new Image(); 
            img.ID = "Image1"
             
            if(item.ItemIndex==0) 
                img.ImageUrl = "~/Image/Image1.gif"
            else 
                img.ImageUrl = "~/Image/Image2.gif"
            
            // add the image to GroupSplitterColumn 
            item["column"].Controls.Clear(); 
            item["column"].Controls.Add(img); 
        } 
   } 


Regards
Shinu
0
Jake
Top achievements
Rank 1
answered on 18 Sep 2009, 10:19 PM
Fantastic! Thank you :)
Tags
Grid
Asked by
Jake
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Jake
Top achievements
Rank 1
Share this question
or