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

disable GridButtonColum on per-row basis?

2 Answers 95 Views
Grid
This is a migrated thread and some comments may be shown as answers.
matt
Top achievements
Rank 1
matt asked on 30 Jan 2011, 11:16 PM
hello,

im on an older version of RadControls for ASP.NET AJAX ("2009.2 826") but i think the answer to my question should be pretty straight-forward.

i have a RadGrid that lists items on a page. these rows include the use of a GridButtonColumn of type Delete, like so:

<Telerik:GridButtonColumn CommandName="Delete" ButtonType="LinkButton" Text="Delete" UniqueName="deleteColumn" />

... my question -- how can i disable the visibility of this column on a per-row basis, dependent on the value of another column in the grid's DataSource? some rows are something i want the user to be able to delete, some rows are not. the rows that cannot be deleted should still allow the user to edit the row via the GridEditCommandColumn we're also using.


thanks!
matt

2 Answers, 1 is accepted

Sort by
0
Accepted
Shinu
Top achievements
Rank 2
answered on 31 Jan 2011, 06:09 AM
Hello Matt,

You can try the following code snippet to achieve your requirement.

C#:
protected void RadGrid1_ItemDataBound(object sender, Telerik.Web.UI.GridItemEventArgs e)
    {
        if (e.Item is GridDataItem)
        {
            GridDataItem item = (GridDataItem)e.Item;
            string s1 = item["EmployeeID"].Text;
            LinkButton deleteBtn = (LinkButton)item["deleteColumn"].Controls[0];
            if (s1 == "1")//Checking for condition
            {
                deleteBtn.Visible = false;
            }
        }
    }

Thanks,
Shinu.
0
matt
Top achievements
Rank 1
answered on 05 Feb 2011, 06:41 PM
thank you so much, Shinu!
Tags
Grid
Asked by
matt
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
matt
Top achievements
Rank 1
Share this question
or