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";
        }
    }

Advertisements

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

  1. Appreciating the time and energy you put into
    your website and in depth information you provide. It’s great to come across a blog every once in a while that isn’t the same old
    rehashed information. Excellent read! I’ve bookmarked your site and I’m adding your RSS feeds to my Google account.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s