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

hide commanditemdisplay from code behind

3 Answers 170 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Ryan
Top achievements
Rank 1
Ryan asked on 22 Oct 2012, 03:21 AM
Hi all,
     I have a grid in which i have used commanditemdisplay. Can I hide it from the code behind. If yes how??
thanks for all replies
RT

3 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 22 Oct 2012, 03:35 AM
Hi,

Please try the following code snippet.

C#:
protected void RadGrid1_PreRender(object sender, EventArgs e)
{
    foreach (GridDataItem item in RadGrid1.Items)
    {
        item.OwnerTableView.CommandItemDisplay = GridCommandItemDisplay.None;
        item.OwnerTableView.Rebind();
    }
}

Thanks,
Shinu.
0
Atlas
Top achievements
Rank 1
answered on 14 Dec 2012, 07:21 PM
This doesn't work for me. I put break points on the PreRender event and the for each loop.
I get to the PreRender event, but never step into the foreach.
Why wouldn't this work?
protected void RadGrid1_PreRender(object sender, EventArgs e)
{
    foreach (GridDataItem item in RadGrid1.Items)
    {
        item.OwnerTableView.CommandItemDisplay = !_canEdit ? GridCommandItemDisplay.None : GridCommandItemDisplay.Top;
        item.OwnerTableView.Rebind();
    }
}
0
Shinu
Top achievements
Rank 2
answered on 17 Dec 2012, 04:40 AM
Hi,

Try the following code to achieve your scenario.
C#:
protected void RadGrid2_PreRender(object sender, EventArgs e)
{
  GridCommandItem item = (GridCommandItem)RadGrid2.MasterTableView.GetItems(GridItemType.CommandItem)[0];
  item.Display = false;
}

Thanks,
Shinu.
Tags
Grid
Asked by
Ryan
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Atlas
Top achievements
Rank 1
Share this question
or