This is a migrated thread and some comments may be shown as answers.
Conditional Delete
2 Answers 6 Views
This is a migrated thread and some comments may be shown as answers.
RB
Top achievements
Rank 1
RB asked on 21 Apr 2014, 10:44 PM
I have a boolean ShowDelete. If it is true, Delete button in the grid columns should be visible. Not otherwise. How can I achieve this?

2 Answers, 1 is accepted

Sort by
0
Accepted
Princy
Top achievements
Rank 1
answered on 22 Apr 2014, 04:36 AM
Hi RB,

Please have a look into the sample code snippet for hiding/showing the delete button of RadGrid based on the Boolean value.

ASPX:
<telerik:RadGrid ID="radgrdOrders" runat="server" DataSourceID="SqlDataSource1" AutoGenerateDeleteColumn="true" AutoGenerateColumns="false" OnItemDataBound="radgrdOrders_ItemDataBound">
    <MasterTableView>
        <Columns>
            <telerik:GridBoundColumn DataField="OrderID" UniqueName="OrderID">
            </telerik:GridBoundColumn>
            <telerik:GridBoundColumn DataField="CustomerID" UniqueName="CustomerID">
            </telerik:GridBoundColumn>
            <telerik:GridBoundColumn DataField="Status" UniqueName="Status">
            </telerik:GridBoundColumn>
        </Columns>
    </MasterTableView>
</telerik:RadGrid>

C#:
protected void radgrdOrders_ItemDataBound(object sender, Telerik.Web.UI.GridItemEventArgs e)
{
    foreach (GridDataItem dataItem in radgrdOrders.Items)
    {
        LinkButton deleteBtn = (LinkButton)dataItem.FindControl("AutoGeneratedDeleteButton");
        string statusCheck = dataItem["Status"].Text;
        if (statusCheck == "False")
            deleteBtn.Visible = false;
    }
}

Thanks,
Princy.
0
RB
Top achievements
Rank 1
answered on 22 Apr 2014, 05:51 PM
Thanks
Asked by
RB
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 1
RB
Top achievements
Rank 1
Share this question
or