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

How to set image url if DataValue is null

1 Answer 327 Views
BinaryImage
This is a migrated thread and some comments may be shown as answers.
sabarishbabu
Top achievements
Rank 1
sabarishbabu asked on 12 Sep 2009, 05:20 AM
Hi,

I have RadBinaryImage controls in DataBound column in RadGrid.

I want to show a default  image if DataValue in Datasource is null.

(ie.) I need to set ImageUrl if DataValue is null.

Thans,
Sabarish.

1 Answer, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 12 Sep 2009, 08:04 AM
Hello Sabarish,

Try out the following code to achieve the required:
c#:
protected void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e) 
    { 
        if (e.Item is GridDataItem) 
        { 
            GridDataItem dataItem = (GridDataItem)e.Item; 
            if (((RadBinaryImage)dataItem["BinaryImageColumnUniqueName"].Controls[0]).ImageUrl == ""
            { ((RadBinaryImage)dataItem["BinaryImageColumnUniqueName"].Controls[0]).ImageUrl = "~/Images/Image1.gif"
            } 
        } 
   } 

Thanks
Shinu.
Tags
BinaryImage
Asked by
sabarishbabu
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Share this question
or