This is a migrated thread and some comments may be shown as answers.

[Solved] Radgrid Command Item Removal

5 Answers 560 Views
Grid
This is a migrated thread and some comments may be shown as answers.
DON
Top achievements
Rank 1
DON asked on 25 Jun 2009, 08:34 PM
Hi All,

I am using a RadGrid that including Add Item and Refresh bar on the top of Grid.  However, I only need Refresh to show and Add Item must hide/disappear.  I did try CommandItemDisplay="Top" CommandItemSettings-AddNewRecordText="" inside MasterTableView and the Text of Add Item is not show up but + sign image is still there.  So, my question is how can I remove + sign image?

Let me know if anyone has any idea.

Thanks and Appreciations

-Don

5 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 26 Jun 2009, 04:56 AM
Hello Don,

You can try out the following code to remove the AddNewRecord button form the command item row of the grid:
c#:
 protected void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e)  
    {  
        GridCommandItem cmdItem = (GridCommandItem)RadGrid1.MasterTableView.GetItems(GridItemType.CommandItem)[0];  
        ((Button)cmdItem.FindControl("AddNewRecordButton")).Visible = false;// remove the image button 
        ((LinkButton)cmdItem.FindControl("InitInsertButton")).Visible = false;//remove the link button  
    }  
  

Thanks
Princy.
0
Daniel
Telerik team
answered on 26 Jun 2009, 07:41 AM
Hello Don,

An bit easier way is shown below:
protected void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e) 
    GridItem cmdItem = RadGrid1.MasterTableView.GetItems(GridItemType.CommandItem)[0]; 
    cmdItem.FindControl("AddNewRecordButton").Parent.Visible = false

Regards,
Daniel
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
DON
Top achievements
Rank 1
answered on 26 Jun 2009, 12:46 PM
Hi,

Sorry I marked as Answer but unfortunely, it's not resolving my issue because code snippet you gave me is an Event when ItemDataBound and I would not want this event but I need is when the Page_Load, it should hide/remove  +  sign image and its link as well.  In my Gridview, I bind with a Data Source using "Select * from customer where customerid = @CustomerId"

Let me know if you guys have any ideas.

Thanks,

-Don
0
DON
Top achievements
Rank 1
answered on 26 Jun 2009, 12:49 PM
Hi,

Your code is not resolving my issue (see my reply on above thread).  Basically, I would not want ItemDataBound event, I just want + sign image is hidden when the page is load.

Thanks,

-Don
0
Murad Ajani
Top achievements
Rank 1
answered on 21 Aug 2009, 09:02 PM
Hi Don,

Take a look at Dimo's response here in this other thread, it may help:

http://www.telerik.com/community/forums/aspnet-ajax/beta/radgrid-hide-addnew.aspx#551874

Basically you want to use the ItemCreated event, not the ItemDataBound event...
Tags
Grid
Asked by
DON
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Daniel
Telerik team
DON
Top achievements
Rank 1
Murad Ajani
Top achievements
Rank 1
Share this question
or