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

set visible false for CommandItemSettings AddNewRecordText

2 Answers 279 Views
Grid
This is a migrated thread and some comments may be shown as answers.
ARUN RAJA
Top achievements
Rank 1
ARUN RAJA asked on 30 Jul 2010, 06:09 PM
hi
  how to set visible false for CommandItemSettings AddNewRecordText in codebehind(page load event)
for ex(the grid have tow columns first one is id and second one is name,the id when 0 the CommandItemSettings AddNewRecordText is set visible false,when id=1 then it visible true

2 Answers, 1 is accepted

Sort by
0
Accepted
Shinu
Top achievements
Rank 2
answered on 02 Aug 2010, 06:19 AM
Hello Arun,

The pageLoad event is too early in rendering the GridCommandItem and hence you can try the following code in PreRender event of grid.

C#:
protected void RadGrid1_PreRender(object sender, EventArgs e)
{
    // Check for the condition
    GridCommandItem cmdItem = (GridCommandItem)RadGrid1.MasterTableView.GetItems(GridItemType.CommandItem)[0];
    ((LinkButton)cmdItem.FindControl("InitInsertButton")).Parent.Visible = false// Hide the buttons
}

Another options is setting the 'ShowAddNewRecordButton' property to false as shown below.
C#:
protected void Page_Load(object sender, EventArgs e)
{
    RadGrid1.MasterTableView.CommandItemSettings.ShowAddNewRecordButton = false;
}

 
-Shinu.
0
ARUN RAJA
Top achievements
Rank 1
answered on 02 Aug 2010, 09:02 AM
Thanks Shinu.its working
Tags
Grid
Asked by
ARUN RAJA
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
ARUN RAJA
Top achievements
Rank 1
Share this question
or