How to Set Visible=false/true or assign Text for ImageButton/LinkButton in a RadGrid command template


Normally we can’t find controls in grid using Codebehind but we can find these by Placing some code in OnItemDataBound Event
so first bind OnItemDataBound event and add following code snippet to it…

protected void radgrd_Charges_ItemDataBound(object sender, GridItemEventArgs e)
    {
        if (e.Item is GridCommandItem)
        {
            GridCommandItem commandItem = (GridCommandItem)e.Item;
            ImageButton ibn_Print = (ImageButton)commandItem.FindControl("ibn_Print");
            LinkButton lnk_Print = (LinkButton)commandItem.FindControl("lnk_Print");
            ibn_Print.Visible = false;
            lnk_Print.Visible = false;
            ibn_Print.ImageUrl = "~/Images/PrintandSave.png";
            lnk_Print.Text = "Pritn & Save";
        }
    }