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

Disable particular Edit buttons based on DB value

1 Answer 82 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Samantha
Top achievements
Rank 1
Samantha asked on 14 Jan 2011, 07:03 PM
I have a RadGrid nested in another RadGrid.

In the nested RadGrid I have enabled Allow Automatic Updates and Deletes.   However I want to disable or set the value of these buttons to be invisible if a value in my SQL database = 1.  This field is in the NestedGrid - although set to visible = false.

How would y'all go about hiding the buttons?  Do I need to remove the Automatic Updates / Deletes and add custom buttons?

1 Answer, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 17 Jan 2011, 08:42 AM
Hello Samantha,

Here is a sample code snippet which shows how to achieve this.

ASPX:
<DetailTables>
   <telerik:GridTableView Name="DetailTable1" runat="server" >
     <Columns>
       <telerik:GridEditCommandColumn UniqueName="EditCommandColumn">
       </telerik:GridEditCommandColumn>
       .   .   .    .   .   .   .
    </Columns>
       .   .   .  .  .   .   .   .   .
 </DetailTables>

C#:
protected void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e)
   {
       if (e.Item is GridDataItem && e.Item.OwnerTableView.Name == "DetailTable")
       {
           GridDataItem item = (GridDataItem)e.Item;
           DataRowView rowview = (DataRowView)item.DataItem;
           if (rowview["FieldName"].ToString() == "200")//your condition
           {
               LinkButton btn = (LinkButton)item["EditCommandColumn"].Controls[0];
               btn.Enabled = false;
           }
        }
     }

Thanks,
Princy.
Tags
Grid
Asked by
Samantha
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Share this question
or