I am using the RadGrid and am inserting an image into a GridBoundColumn using the ItemDataBound event, this all works fine. However when I click on a column to sort all the text columns are sorted correctly but the images do not move.
I looked at the zip file but unfortunately could see no Image Column in the example you provided. I am not sure if I am missing something.
I have looked at the Telerik example site and seen the image column in action and it does work with the sorting however that doesn't really suit our purpose as there needs to be some logic involved in selecting the image which is why we need to use the item databound event. For example we have an alert column and depending on the type of alert determines the type of image(s) to display so we can't hard code it at design time.
I have tried adding an image control to a GridBoundColumn column and a template column with an image control in it, neither of which I have got to work. Is there a way of assigning the image url to an image column in the databound event?
Please excuse me for attaching a wrong project to my previous post.
To this post I am attaching 2 projects - the first is using GridImageColumn in which the Url of the image is set declarative and in the second there is a GridTemplateColumn with an Image in its ItemTemplate and the ImageUrl is set in the ItemDataBound event handler. In both of them sorting is working fine.
Please take a look at them and tell me what are the differences in your scenario.
you are using ItemDataBound event with GridTemplateColumn.
What about using GridImageColumn?
How can I catch GridImageColumn and change its ImageUrl?
answered on 22 Sep 2009, 11:37 AM
You can reference the cell from the GridImageColumn in which the image resides using its column unique name and then get the first control in it (Controls) which should be the actual asp Image. Thus inside the ItemCreated or ItemDataBound server handler of the grid you can change the image url of a certain image programmatically (like this is done previously with the image from the template column).