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

Insert Icons in anColumn

3 Answers 255 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Christian
Top achievements
Rank 1
Christian asked on 16 Mar 2009, 11:55 AM
I use a GridTemplateColumn in the RadGrid and now I have to insert icons in this columns, edpending of the flag field in the datatable.

How can I realize this?

thanks for assistance

Christian 

3 Answers, 1 is accepted

Sort by
0
Accepted
Shinu
Top achievements
Rank 2
answered on 16 Mar 2009, 12:23 PM
Hello Christian,

I tried following code snippet for setting the icon for each row depending on the flag field in datatable.
ASPX:
<telerik:GridTemplateColumn UniqueName="TempCol"
    <ItemTemplate> 
        <asp:Image runat="server" ID="Image" />                     
    </ItemTemplate>                     
</telerik:GridTemplateColumn> 

CS:
protected void RadGrid1_PreRender(object sender, EventArgs e) 
    foreach (GridDataItem item in RadGrid1.MasterTableView.Items) 
    { 
        Image img = (Image)item["TempCol"].FindControl("Image"); 
        if (item["CustomerID"].Text == "ALFKI"// Check for the condition 
        { 
            img.ImageUrl = "../Images/clockHover.gif"// Set the image Url 
        } 
        else 
        { 
            img.ImageUrl = "../Images/datePickerPopup.gif"// Set the image Url 
        } 
    } 

Thanks,
Shinu.
0
Christian
Top achievements
Rank 1
answered on 16 Mar 2009, 02:37 PM
Is it possible to put two images into an itemTemplate.

I wwork with

 

item("Images").Controls.Add(img1)   
item("Images").Controls.Add(img2) 

and int doesn't work

Christian

 

0
Christian
Top achievements
Rank 1
answered on 16 Mar 2009, 02:56 PM
Fixed.

It was my fault!
Tags
Grid
Asked by
Christian
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Christian
Top achievements
Rank 1
Share this question
or