5 Answers, 1 is accepted
0
Princy
Top achievements
Rank 2
answered on 30 Jun 2014, 10:25 AM
Hi Mike,
I guess you want to hide the AddNewRecord based on some condition, you can use the PreRender event for this, and to hide a rows edit button you can check condition in the ItemDataBound event as follows:
C#:
Thanks,
Princy
I guess you want to hide the AddNewRecord based on some condition, you can use the PreRender event for this, and to hide a rows edit button you can check condition in the ItemDataBound event as follows:
C#:
protected void RadGrid1_PreRender(object sender, EventArgs e){ if (Some Condition) { RadGrid1.MasterTableView.CommandItemSettings.ShowAddNewRecordButton = false; RadGrid1.Rebind(); }else { RadGrid1.MasterTableView.CommandItemSettings.ShowAddNewRecordButton = true; RadGrid1.Rebind(); }}protected void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e){ if(e.Item is GridDataItem) { GridDataItem dataItem = (GridDataItem)e.Item; if (some condition) { //Access the edit button using its unique name LinkButton lnkEdit = (LinkButton)dataItem["GridEditCommandColumn"].Controls[0]; lnkEdit.Enabled = false; } }}Thanks,
Princy
0
MikeS
Top achievements
Rank 1
answered on 30 Jun 2014, 11:08 AM
hello princy.
i was able to hide edit button using this code:
however, i cannot do the same thing to delete button. i tried FindControl("DeleteButton") but it doesnt work.
i've already found a way to hide insertrow.
thanks in advance
i was able to hide edit button using this code:
Private Sub RadGrid1_ItemCreated(sender As Object, e As GridItemEventArgs) Handles RadGrid1.ItemCreated
If TypeOf e.Item Is GridDataItem Then
Dim btnEdit As ImageButton = TryCast(e.Item.FindControl("EditButton"), ImageButton)If Not (Condition) Then btnEdit .Visible = FalseEnd If
End If
End Subhowever, i cannot do the same thing to delete button. i tried FindControl("DeleteButton") but it doesnt work.
i've already found a way to hide insertrow.
thanks in advance
0
MikeS
Top achievements
Rank 1
answered on 30 Jun 2014, 11:54 AM
actually i need to disable InsertItemDisplay, and i still cant do it properly.
There is a way to disable InsertItemDisplay on code behind?
There is a way to disable InsertItemDisplay on code behind?
0
Accepted
Princy
Top achievements
Rank 2
answered on 01 Jul 2014, 04:23 AM
Hi Mike,
I'm not clear about your requirement on hiding the InsertItemDisplay, if you want to hide the insert form you can set RadGrid1.MasterTableView.IsItemInserted = false. To hide a delete button try the following. If this doesn't help, please elaborate on your requirement.
APSX:
VB:
Thanks,
Princy
I'm not clear about your requirement on hiding the InsertItemDisplay, if you want to hide the insert form you can set RadGrid1.MasterTableView.IsItemInserted = false. To hide a delete button try the following. If this doesn't help, please elaborate on your requirement.
APSX:
<telerik:GridButtonColumn UniqueName="DeleteButton" Text="Delete"></telerik:GridButtonColumn>VB:
Protected Sub RadGrid1_ItemDataBound(sender As Object, e As GridItemEventArgs) If TypeOf e.Item Is GridDataItem Then Dim dataItem As GridDataItem = DirectCast(e.Item, GridDataItem) If condition Then Dim lnkDelete As LinkButton = DirectCast(dataItem("DeleteButton").Controls(0), LinkButton) lnkDelete.Visible = False End If End IfEnd SubThanks,
Princy
0
MikeS
Top achievements
Rank 1
answered on 01 Jul 2014, 09:04 AM
Hi Princy,
i was able to disable insert row using RadGrid1.MasterTableView.IsItemInserted = false.
Also, i solved the problem with the delete button in the editRow of the grid so i have all my problems solved.
thanks!
i was able to disable insert row using RadGrid1.MasterTableView.IsItemInserted = false.
Also, i solved the problem with the delete button in the editRow of the grid so i have all my problems solved.
thanks!