This is a migrated thread and some comments may be shown as answers.
To Display Image before the grid column text
5 Answers 24 Views
This is a migrated thread and some comments may be shown as answers.
Krishnan LN
Top achievements
Rank 1
Krishnan LN asked on 19 Feb 2010, 09:34 AM
Hi,
Im using the delf referencing radgrid. I need a requirement to display a image before the text in the grid column. I dont require a new image column for that, just the image before the text. Can you help me out?

Krishnan

5 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 1
answered on 19 Feb 2010, 10:07 AM
Hi,

You can access the item in the ItemCreated event and add an image and a label with the required text to Controls collection .
C#
protected void RadGrid1_ItemCreated(object sender, GridItemEventArgs e) 
    { 
        if (e.Item is GridDataItem) 
        { 
            GridDataItem dataItem = (GridDataItem)e.Item; 
            Image img=new Image(); 
            dataItem["ColumnUniqueName"].Controls.Add(img); 
            
        } 
   } 






Thanks,
Shinu
0
Krishnan LN
Top achievements
Rank 1
answered on 19 Feb 2010, 11:23 AM
Hi shinu,
Thanks for quick reply. I still have the issue. Im not able to see the image. Following is the code.

 if (e.Item is GridDataItem)  
            {  
                GridDataItem dataItem = (GridDataItem)e.Item;  
                Image img = new Image();  
                img.ImageUrl = "/Images/plus.gif";  
                dataItem["Name"].Controls.Add(img);  
 
            }   

thanks,
Krishnan
0
Iana Tsolova
Telerik team
answered on 19 Feb 2010, 11:54 AM
Hello Krishnan,

Try adding the code for the dynamic image on ItemDataBound as well on ItemCreated and see if it makes any difference.

Let me know how it goes.

Best wishes,
Iana
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0
Krishnan LN
Top achievements
Rank 1
answered on 19 Feb 2010, 12:12 PM
Hi can you give any sample code for it please
0
Shinu
Top achievements
Rank 1
answered on 20 Feb 2010, 04:39 AM
Hi,

Please have a  look at the link below to know more on how to access cells and rows in ItemCreated/ItemDataBound event:

Accessing cells and rows

Thanks,
Shinu



Tags
Grid
Asked by
Krishnan LN
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 1
Krishnan LN
Top achievements
Rank 1
Iana Tsolova
Telerik team
Share this question
or