Thursday, July 02, 2009

RadGrid: hide add new and refresh buttons from code behind

protected void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e)
{
if (e.Item is GridCommandItem)
{
GridCommandItem cmditm = (GridCommandItem)e.Item;
//to hide AddNewRecord button
cmditm.FindControl("InitInsertButton").Visible = false;//hide the text
cmditm.FindControl("AddNewRecordButton").Visible = false;//hide the image

//to hide Refresh button
cmditm.FindControl("RefreshButton").Visible = false;//hide the text
cmditm.FindControl("RebindGridButton").Visible = false;//hide the image


}
}

6 comments:

Anonymous said...

Very helpful. Thank you for posting.

Mikhail said...

Thanks, that's what i needed.

astro said...

Thanks a lot!

Anonymous said...

Awesome...

Alex Ubeda said...

Thanks it helps a lot !!!

Anonymous said...

Thanks a lot!!! its very helpfull!!!