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

Hide Edit Button Conditionally

1 Answer 191 Views
AJAX and Web 2.0
This is a migrated thread and some comments may be shown as answers.
Julie
Top achievements
Rank 1
Julie asked on 15 Aug 2011, 07:59 PM
This is my first post so I am sorry ahead of time if this is the wrong forum.....

I am trying to hide the edit button in a radgrid if the field LOCKED is set to 1 but it is not working - any ideas?

Thanks
Julie


private void RadGrid1_ItemDataBound(object sender, Telerik.Web.UI.GridItemEventArgs e)
{
    if (e.Item is GridDataItem)
    {
        GridDataItem dataItem = e.Item as GridDataItem;
        GridEditManager manager = dataItem.EditManager;
        IGridColumnEditor editor = manager.GetColumnEditor("Locked");
        TextBox box = (editor as GridTextBoxColumnEditor).TextBoxControl;
        if (box.Text == "1")
        {
            dataItem["EditCommandColumn"].Controls[0].Visible = false;
        }
        else
        {
            dataItem["EditCommandColumn"].Controls[0].Visible = true;
        }
    }
}

1 Answer, 1 is accepted

Sort by
0
Andrey
Telerik team
answered on 18 Aug 2011, 02:11 PM
Hi Julie,

If I understand you right, you should do something like this:

protected void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e)
    {
        if (e.Item is GridDataItem)
        {
            GridDataItem dataItem = e.Item as GridDataItem;
            if (dataItem["Locked"].Text == "1")
            {
                dataItem["EditCommandColumn"].Controls[0].Visible = false;
            }
            else
            {
                dataItem["EditCommandColumn"].Controls[0].Visible = true;
            }
        }
    }

If that is not the case, please provide a sample project.

Regards,
Andrey
the Telerik team

Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.

Tags
AJAX and Web 2.0
Asked by
Julie
Top achievements
Rank 1
Answers by
Andrey
Telerik team
Share this question
or