Hi:
I have an GridTemplateColumn from the Norhtwind db as follows:
I need to hide the appropriate control if adding or editing. The ItemCommand event seems to be prior to the edit mode, so I am trying to use the ItemDataBound event. The following code works fine in edit but how do I differentiate between add and edit? Any other server side solutions are welcome.
Phil
I have an GridTemplateColumn from the Norhtwind db as follows:
| <Telerik:GridTemplateColumn HeaderText="CustomerID" UniqueName="CustomerIDColumn" AllowFiltering="True" > |
| <ItemTemplate> |
| <asp:Label ID="CustomerIDLabel" runat="server" Text='<%# Eval("CustomerID") %>' /> |
| </ItemTemplate> |
| <EditItemTemplate> |
| <asp:Label ID="CustomerIDLabel" runat="server" Text='<%# Eval("CustomerID") %>' /> |
| <asp:TextBox ID="CustomerIDTextBox" runat="server" Text='<%# Bind("CustomerID") %>' /> |
| </EditItemTemplate> |
| </Telerik:GridTemplateColumn> |
| protected void customersGrid_ItemDataBound(object sender, GridItemEventArgs e) |
| { |
| if (e.Item is GridEditableItem && e.Item.IsInEditMode) |
| { |
| // GridTemplateColumn |
| GridEditFormItem _editItem = e.Item as GridEditFormItem; |
| TableCell cell = _editItem["CustomerIDColumn"]; |
| (cell.Controls[0].FindControl("CustomerIDLabel") as Label).Visible = true; |
| (cell.Controls[0].FindControl("CustomerIDTextBox") as TextBox).Visible = false; |
| } |
| } |