I need to disable and enable a field in a popup edit form depending on edit or insert mode. The grid has a MasterTableView and One Detail Table. When I expand the MasterTableView, the Detail Table has a command Item Insert link along with edit and delete buttons. I tried to do this in the RadGrid1_ItemCommand routine when the command is "InitInsert" but I cannot get a handle on the field I need. How can I do this?
| protected void RadGrid1_ItemCommand(object source, Telerik.Web.UI.GridCommandEventArgs e) |
| { |
| if ("Detail".Equals(e.Item.OwnerTableView.Name)) |
| { |
| if ("InitInsert".Equals(e.CommandName)) |
| { |
| (e.Item as GridEditableItem)["PackageName"].Enabled = true; |
| } |
| } |
| } |
| <telerik:RadGrid ID="RadGrid1" runat="server" DataSourceID="SqlDataSource1" |
| GridLines="None" AutoGenerateColumns="False" |
| OnInsertCommand="RadGrid1_InsertCommand" |
| OnItemUpdate="RadGrid1_UpdateCommand" |
| OnItemCommand="RadGrid1_ItemCommand"> |
| <HeaderContextMenu EnableTheming="True"> |
| <CollapseAnimation Type="OutQuint" Duration="200"></CollapseAnimation> |
| </HeaderContextMenu> |
| <MasterTableView datasourceid="SqlDataSource1" DataKeyNames="Group_Name" |
| AllowFilteringByColumn="True" Name="Header"> |
| <DetailTables> |
| <telerik:GridTableView runat="server" DataSourceID="SqlDataSource2" |
| DataKeyNames="Group_Name" CommandItemDisplay="Top" Name="Detail" |
| AllowAutomaticUpdates="False" EditMode="PopUp"> |
| <ParentTableRelation> |
| <telerik:GridRelationFields DetailKeyField="Group_Name" MasterKeyField="Group_Name" /> |
| </ParentTableRelation> |
| <CommandItemSettings AddNewRecordImageUrl="\Images\AddRecord.gif" /> |
| <RowIndicatorColumn> |
| <HeaderStyle Width="20px" /> |
| </RowIndicatorColumn> |
| <ExpandCollapseColumn> |
| <HeaderStyle Width="20px" /> |
| </ExpandCollapseColumn> |
| <Columns> |
| <telerik:GridEditCommandColumn> |
| </telerik:GridEditCommandColumn> |
| <telerik:GridButtonColumn CommandName="Delete" Text="Delete" |
| UniqueName="column3"> |
| </telerik:GridButtonColumn> |
| <telerik:GridBoundColumn DataField="Package_Name" UniqueName="PackageName" HeaderText="Package Name" |
| Visible="True" ReadOnly="True"> |
| </telerik:GridBoundColumn> |
| <telerik:GridBoundColumn DataField="Group_Name" UniqueName="column2" |
| Visible="False" Display="False" ReadOnly="True"> |
| </telerik:GridBoundColumn> |
| <telerik:GridBoundColumn DataField="ConnectionString" |
| UniqueName="ConnectionString" HeaderText="Connection String"> |
| </telerik:GridBoundColumn> |
| <telerik:GridBoundColumn DataField="FileId" UniqueName="FileId" Visible="False" |
| Display="False" ReadOnly="True"> |
| </telerik:GridBoundColumn> |
| <telerik:GridDropDownColumn DataField="Active" ForceExtractValue="InEditMode" |
| HeaderText="Active" UniqueName="Active" DataSourceID="SqlDataSource3" ListTextField="Active" |
| ListValueField="Active"> |
| </telerik:GridDropDownColumn> |
| <telerik:GridDropDownColumn DataField="InProcess" ForceExtractValue="InEditMode" |
| HeaderText="In Process" UniqueName="InProcess" DataSourceID="SqlDataSource3" ListTextField="Active" |
| ListValueField="Active"> |
| </telerik:GridDropDownColumn> |
| </Columns> |
| <EditFormSettings CaptionFormatString="test"> |
| <EditColumn UniqueName="EditCommandColumn1"> |
| </EditColumn> |
| </EditFormSettings> |
| </telerik:GridTableView> |
| </DetailTables> |
| <ParentTableRelation> |
| <telerik:GridRelationFields DetailKeyField="Group_Name" /> |
| </ParentTableRelation> |
| <RowIndicatorColumn> |
| <HeaderStyle Width="20px"></HeaderStyle> |
| </RowIndicatorColumn> |
| <ExpandCollapseColumn visible="True"> |
| <HeaderStyle Width="20px"></HeaderStyle> |
| </ExpandCollapseColumn> |
| <Columns> |
| <telerik:GridBoundColumn DataField="Application_Name" UniqueName="column1" |
| HeaderText="Application Name"> |
| </telerik:GridBoundColumn> |
| <telerik:GridBoundColumn DataField="Group_Name" UniqueName="Group_Name" |
| HeaderText="Group Name"> |
| </telerik:GridBoundColumn> |
| </Columns> |
| </MasterTableView> |
| <FilterMenu EnableTheming="True"> |
| <CollapseAnimation Type="OutQuint" Duration="200"></CollapseAnimation> |
| </FilterMenu> |
| </telerik:RadGrid> |