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

Disable Edit button based on a specific value in the row

1 Answer 461 Views
Grid
This is a migrated thread and some comments may be shown as answers.
saravanan k
Top achievements
Rank 1
saravanan k asked on 12 Apr 2010, 01:03 PM
Hi,

I would like to implement the following:

Disable the edit button for a particular row, based on a specific value in its column.

For ex. If a grid has 3 columns A,B,C and if B contains "Apple", the edit button for that row must be disabled.

Thanks
Sarvanan

1 Answer, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 12 Apr 2010, 02:08 PM
Hello Saravanan,

You can disable the edit button for a particular row based on condition, by using following code.

C#:

 
protected void RadGrid1_ItemDataBound(object sender, Telerik.Web.UI.GridItemEventArgs e)    
    {    
        if (e.Item is GridDataItem )    
        {    
            GridDataItem item = (GridDataItem)e.Item;    
            if (item["columnB"].Text == "apple")    
            {   
                // Use this code if using ButtonColumn with ColumnUniqueName  'EditColumn'   
                LinkButton btn = (LinkButton)item["EditColumn"].Controls[0];    
                btn.Enabled = false;    
                   
                //  Use the following code if you are using autogeneratedEditColumn   
                LinkButton btn2 = (LinkButton)item["AutoGeneratedEditColumn"].Controls[0];    
                btn2.Enabled = false;    
            }    
        }    
    }   

Regards,
Shinu.
Tags
Grid
Asked by
saravanan k
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Share this question
or