On ItemDataBound of the mastertable I am hiding the delete and edit columns for certains rows.
This part is working perfectly, except for when the detailtable is displayed. When the detailtable is displayed it rebinds the whole grid but does not call ItemDataBound for the mastertable so the delete and edit columns are displayed again.
I can remove the edit and delete buttons for the parentItem but not any of the other rows. How do I remove it from the other rows?
This part is working perfectly, except for when the detailtable is displayed. When the detailtable is displayed it rebinds the whole grid but does not call ItemDataBound for the mastertable so the delete and edit columns are displayed again.
| protected void grdEvents_ItemDataBound(object sender, GridItemEventArgs e) |
| { |
| if (e.Item.ItemType == GridItemType.Item || e.Item.ItemType == GridItemType.AlternatingItem) |
| { |
| GridDataItem item = (GridDataItem)e.Item; |
| if (e.Item.OwnerTableView.Name == "EventsGrid")//This is the mastertable |
| { |
| ProtocolRegimenEvent preItem = (ProtocolRegimenEvent)e.Item.DataItem; |
| TableCell td = item[grdEvents.Columns.FindByUniqueNameSafe("colDelete")]; |
| if (preItem.EventTypeId != (int)Enums.EventTypes.Scheduled) |
| { |
| if (td != null && td.Controls.Count > 0) |
| { |
| td.Controls.RemoveAt(0); |
| Label lbl = new Label(); |
| lbl.Text = "-"; |
| td.Controls.Add(lbl); |
| } |
| if (preItem.EventTypeId == (int)Enums.EventTypes.Unscheduled) |
| { |
| td = item[grdEvents.Columns.FindByUniqueNameSafe("colEdit")]; |
| if (td != null && td.Controls.Count > 0) |
| { |
| td.Controls.RemoveAt(0); |
| Label lbl = new Label(); |
| lbl.Text = "-"; |
| td.Controls.Add(lbl); |
| } |
| } |
| } |
| } |
| else //This is a detailtable |
| { |
| ProtocolRegimenEventForm preItem = (ProtocolRegimenEventForm)e.Item.DataItem; TableCell td = e.Item.OwnerTableView.ParentItem[grdEvents.Columns.FindByUniqueNameSafe("colDelete")]; if (preItem.EventTypeId != (int)Enums.EventTypes.Scheduled) { //remove buttons } |
| } |
| } |
| } |
I can remove the edit and delete buttons for the parentItem but not any of the other rows. How do I remove it from the other rows?