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

Change Image in Radgrid Column

2 Answers 556 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Jagat
Top achievements
Rank 1
Jagat asked on 29 Jun 2011, 10:18 PM
Hello All,

   I have a RadGrid with EditCommand Column  as the first column in the grid. I have a edit image set for all the rows in that column. I did this by putting the editImageURL property.
Now. My question is, Is there a way to change the Image of that column dynamically based on the value of other column in the grid?

I want to change the first column's image of a grid based on other column value. Can i do it in the aspx page or Is it best way to do it from code behind?

If I have to do it from Code behind, How can I access the image folder( which has all the images  I am using in the project) in my project from code behind. If it is aspx page we can set the property like editImageUrl .

2 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 30 Jun 2011, 06:48 AM
Hello Jaget,
You can try setting the ImageUrl property form code behind as follows.
C#:
protected void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e)
   {
       if (e.Item is GridDataItem)
       {
           GridDataItem item = (GridDataItem)e.Item;
           string value=item["EmployeeID"].Text;
           if(value=="1")
           {
           ImageButton img = (ImageButton)item["EditCommandColumn"].Controls[0];
           img.ImageUrl = "edit.jpg";
           }
       }

Thanks,
Shinu.
0
Jagat
Top achievements
Rank 1
answered on 30 Jun 2011, 05:36 PM
Thank you.. It worked.

Tags
Grid
Asked by
Jagat
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Jagat
Top achievements
Rank 1
Share this question
or