How to Dynamically Change the Image Button of Telerik RadGrid

In order to set the Image for the GridButton Column in Telerik Rad Grid, you need to access the control first from server side and then set the Image dynamically. Here is a sample code.

protected void grdDemo_ItemDataBound(object sender, GridItemEventArgs e)
{
if (e.Item is GridDataItem)
{
var item = (GridDataItem)e.Item;
if() // your condition here
(item["Your GridButton Column's Unique Name "].Controls[0] as ImageButton).ImageUrl = "~/Content/Images/icon_cancel_fade.gif";
}
}

You saw above that I am first getting the control via its unique name, you may know that every columns in Rad Grid has its own unique name in order to perform operation on right controls. Note: You must need to assign the Unique Name before use to avoid unexpected errors Enjoy…..

Leave a Reply