Disable particular Edit buttons based on DB value

2 posts, 0 answers
  1. Samantha
    Samantha avatar
    21 posts
    Member since:
    Apr 2009

    Posted 14 Jan 2011 Link to this post

    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?
  2. Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 17 Jan 2011 Link to this post

    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.
  3. UI for ASP.NET Ajax is Ready for VS 2017
Back to Top