I'm using a RadGrid with a GridAttachmentColumn (ButtonType ImageButton) for download.
Everything is Ok and It works well.
But some of the items of my Grid don't have attached file.
So I would like to set the "visible property" of the button to false when there is no attached file.
Is there a way to do that ?
Thanks a lot.
4 Answers, 1 is accepted
You have to handle the ItemDataBound event and then set the text to blank or clear the controls in that cell, whatever works for yur. Like so:
For the Cells collection you need to set it the correct column index for the attachment column.
I hope that helps.
Many thanks for your answer.
I've had already tried this way.
When I inspect the grdItem.Cells.Controls, this collection is empty.
and grdItem.Cells.Text = "" has no effect.
I thought that It was not the right handler
So I have tried with itemCreated, but no more success...
From Cori's code grdItem has indexer that accepts as parameter column UniqueName. Thus you can use the following:
grdItem["YOUR COLUMN UniqueName"] - this will return the cell for that column in the current data item.
the Telerik team
Hello Nikolay, Hello Cori,
Thanks you for your insistence ! It's works !
It's all my fault !
When I built the GridAttachmentColumn, I set "DataTextField property" to "boo0" and the "UniqueName property" to "AttachmentColumn" (copy/paste from an example...)
And then when I asked grdItem["boo0"], there were nothing !
So I have deleted "UniqueName property" so It take the value of "DataTextField property" value
Silly mistake !
Many Thanks to you both