This is a migrated thread and some comments may be shown as answers.

[Solved] Cannot find control in RadGrid

1 Answer 273 Views
Grid
This is a migrated thread and some comments may be shown as answers.
pmourfield
Top achievements
Rank 1
pmourfield asked on 27 Feb 2013, 02:14 PM
I have the following radgrid markup. Toward the bottom I have an asp Panel that I cannot find using C# FindControl(). If anyone has any tips on how to do this, please let me know.

<telerik:RadGrid runat="server" ID="UnapprovedPOsGrid" AutoGenerateColumns="False"
                                Skin="Metro" DataSourceID="UnapprovedPOsDataSource" AllowAutomaticInserts="true"
                                OnItemCommand="UnapprovedPOsGrid_ItemCommand" OnItemDataBound="UnapprovedPOsGrid_ItemDataBound" OnEditCommand="UnapprovedPOsGrid_EditCommand"
                                AllowAutomaticDeletes="true" AllowAutomaticUpdates="true">
                                <MasterTableView EditMode="EditForms" CommandItemDisplay="Top" DataKeyNames="PO_ID"
                                    ExpandCollapseColumn-ButtonType="LinkButton" ShowHeadersWhenNoRecords="true"
                                    GroupsDefaultExpanded="false" GroupLoadMode="server" ShowGroupFooter="true" DataSourceID="UnapprovedPOsDataSource">
                                    <Columns>
                                        <telerik:GridEditCommandColumn ButtonType="LinkButton" EditText="View" UniqueName="ViewCommandColumn"></telerik:GridEditCommandColumn>
                                        <telerik:GridBoundColumn HeaderText="Purchase Order Number" DataField="PO_ID" />
                                        <telerik:GridBoundColumn HeaderText="Description of Item" DataField="POI_DescriptionOfItem" />
                                        <telerik:GridBoundColumn HeaderText="Employee" DataField="PO_EmployeeName" />
                                        <telerik:GridBoundColumn HeaderText="Vendor" DataField="PO_VendorName">
                                        </telerik:GridBoundColumn>
                                    </Columns>
                                    <EditFormSettings ColumnNumber="3" EditFormType="Template">
                                        <FormTemplate>
                                            <table>
                                                <tr>
                                                    <td>
                                                        <div>
                                                            <strong>Employee Name</strong>
                                                        </div>
                                                        <div>
                                                             <asp:Label runat="server" ID="EmployeeLabel" Text='<%# Bind("PO_EmployeeName") %>'>
                                                            </asp:Label>
                                                        </div>
                                                    </td>
                                                    <td>
                                                        <div>
                                                            <strong>Vendor Name</strong>
                                                        </div>
                                                        <div>
                                                             <asp:Label runat="server" ID="VendorNameLabel" Text='<%# Bind("PO_VendorName") %>'>
                                                            </asp:Label>
                                                        </div>
                                                    </td>
                                                </tr>
                                                <tr>
                                                    <td>
                                                        <div>
                                                            <strong>Vendor Phone</strong>
                                                        </div>
                                                        <div>
                                                             <asp:Label runat="server" ID="VendorPhoneLabel" Text='<%# Bind("PO_VendorPhone") %>'>
                                                            </asp:Label>
                                                        </div>
                                                    </td>
                                                    <td>
                                                        <div>
                                                            <strong>Division Director</strong>
                                                        </div>
                                                        <div>
                                                             <telerik:RadTextBox runat="server" ID="DivisionDirectorApprovalLabel" Text='<%# Bind("PO_DivisionDirectorApproval") %>'>
                                                            </telerik:RadTextBox>
                                                        </div>
                                                    </td>
                                                </tr>
                                                <tr>
                                                    <td>
                                                        <div>
                                                            <strong>Approved By Division Director</strong><br />
                                                            <br />
                                                        </div>
                                                    </td>
                                                    <td>
                                                        <div>
                                                            <asp:CheckBox runat="server" ID="DivisionDirectorApprovalCheckBox" Checked='<%# Bind("PO_DivisionDirectorApproved") %>'
                                                                TextAlign="Left" Enabled="true" /><br />
                                                            <br />
                                                        </div>
                                                    </td>
                                                </tr>
                                                <tr>
                                                    <td>
                                                        <div>
                                                            <strong>Estimated Delivery Date</strong>
                                                        </div>
                                                        <div>
                                                             <asp:Label runat="server" ID="EstimatedDeliveryDateLabel" Text='<%# Bind("PO_EstimatedDeliveryDate") %>'></asp:Label>
                                                        </div>
                                                    </td>
                                                    <td>
                                                        <div>
                                                            <strong>Company Name Ordered In</strong>
                                                        </div>
                                                        <div>
                                                             <asp:Label runat="server" ID="CompanyNameOrderedInLabel" Text='<%# Bind("PO_CompanyNameOrderedIn") %>'
                                                                Enabled="false">                                           
                                                            </asp:Label>
                                                        </div>
                                                    </td>
                                                </tr>
                                                <tr>
                                                    <td>
                                                        <div>
                                                            <strong>Division</strong>
                                                        </div>
                                                        <div>
                                                             <asp:Label runat="server" ID="DivisionLabel" Enabled="false" Text='<%# Bind("PO_Division") %>'>                                           
                                                            </asp:Label>
                                                        </div>
                                                    </td>
                                                    <td>
                                                        <div>
                                                            <strong>Payment Method</strong>
                                                        </div>
                                                        <div>
                                                             <asp:Label runat="server" ID="PaymentMethodLabel" EmptyMessage="Select..."
                                                                Text='<%# Bind("PO_PaymentMethod") %>'>
                                                            </asp:Label>
                                                        </div>
                                                    </td>
                                                </tr>
                                                <tr>
                                                    <td>
                                                        <div>
                                                            <strong>To Be Ordered By</strong>
                                                        </div>
                                                        <div>
                                                             <asp:Label runat="server" ID="ToBeOrderedByLabel" Text='<%# Bind("PO_ToBeOrderedBy") %>'>
                                                            </asp:Label>
                                                        </div>
                                                    </td>
                                                </tr>
                                            </table>
                                            <telerik:RadGrid runat="server" ID="UnapprovedPOsItemsGrid" DataSourceID="UnapprovedPOsItemsDataSource"
                                                OnItemDataBound="UnapprovedPOsItemsGrid_ItemDataBound" AutoGenerateColumns="false">
                                                <MasterTableView CommandItemDisplay="Top" DataKeyNames="PO_ID" ShowHeadersWhenNoRecords="true"
                                                    GroupsDefaultExpanded="false" GroupLoadMode="server" ShowGroupFooter="true" DataSourceID="UnapprovedPOsItemsDataSource">
                                                    <CommandItemTemplate>
                                                        <asp:Label ID="ItemsBeingPurchasedLabel" runat="server" Width="170px" Text="Items Being Purchased"
                                                            Style="font-weight: bold; padding: 5px 0 5px 5px"></asp:Label>
                                                    </CommandItemTemplate>
                                                    <Columns>
                                                        <telerik:GridBoundColumn DataField="PO_ID" Visible="false">
                                                        </telerik:GridBoundColumn>
                                                        <telerik:GridBoundColumn HeaderText="Description of Item" DataField="POI_DescriptionOfItem" />
                                                        <telerik:GridBoundColumn HeaderText="Reason For Purchase" DataField="POI_ReasonForPurchase" />
                                                        <telerik:GridBoundColumn HeaderText="Quantity" DataField="POI_Quantity" FooterAggregateFormatString="<b>Total Quantity: </b>{0}" />
                                                        <telerik:GridBoundColumn HeaderText="Unit Price" DataField="POI_UnitPrice" FooterAggregateFormatString="<b>Total Price: </b>{0}" />
                                                        <telerik:GridBoundColumn HeaderText="Amount" DataField="POI_Amount" FooterAggregateFormatString="<b>Total Amount: </b>{0}" />
                                                        <telerik:GridBoundColumn HeaderText="Price Quoted" DataField="POI_PriceQuoted" FilterControlWidth="80px" />
                                                        <telerik:GridBoundColumn HeaderText="Price Estimated" DataField="POI_PriceEstimated" />
                                                        <telerik:GridBoundColumn HeaderText="Additional Costs" DataField="POI_AdditionalCosts"
                                                            FilterControlWidth="80px" />
                                                        <telerik:GridBoundColumn HeaderText="Explanation of Additional Costs" Display="false"
                                                            DataField="POI_AdditionalCostsExplanation" />
                                                    </Columns>
                                                    <NestedViewSettings DataSourceID="UnapprovedPOsItemsDataSource">
                                                        <ParentTableRelation>
                                                            <telerik:GridRelationFields DetailKeyField="POI_Item_ID" MasterKeyField="POI_Item_ID" />
                                                        </ParentTableRelation>
                                                    </NestedViewSettings>
                                                    <NestedViewTemplate>
                                                        <div style="padding-left: 30px; padding-top: 20px; padding-bottom: 20px;">
                                                            <table>
                                                                <tr>
                                                                    <td>Description of Item
                                                                    </td>
                                                                    <td>
                                                                        <asp:Label runat="server" ID="ItemDescriptionTextBox" Text='<%# Bind("POI_DescriptionOfItem") %>'></asp:Label>
                                                                    </td>
                                                                </tr>
                                                                <tr>
                                                                    <td>Reason For Purchase
                                                                    </td>
                                                                    <td>
                                                                        <asp:Label runat="server" ID="ReasonForPurchaseTextBox" Text='<%# Bind("POI_ReasonForPurchase") %>'>
                                                                        </asp:Label>
                                                                    </td>
                                                                </tr>
                                                                <tr>
                                                                    <td>Quantity
                                                                    </td>
                                                                    <td>
                                                                        <asp:Label runat="server" ID="QuantityNumericTextBox" Text='<%# Bind("POI_Quantity") %>'>
                                                                        </asp:Label>
                                                                    </td>
                                                                </tr>
                                                                <tr>
                                                                    <td>Unit Price
                                                                    </td>
                                                                    <td>
                                                                        <asp:Label runat="server" ID="UnitPriceNumericTextBox" Text='<%# Bind("POI_UnitPrice") %>'>
                                                                        </asp:Label>
                                                                    </td>
                                                                </tr>
                                                                <tr>
                                                                    <td>Amount (Q x Price)
                                                                    </td>
                                                                    <td>
                                                                        <asp:Label runat="server" ID="AmountNumericTextBox" Text='<%# Bind("POI_Amount") %>'>
                                                                        </asp:Label>
                                                                    </td>
                                                                </tr>
                                                                <tr>
                                                                    <td>Price Quoted
                                                                    </td>
                                                                    <td>
                                                                        <asp:Label runat="server" ID="PriceQuotedNumericTextBox" Text='<%# Bind("POI_PriceQuoted") %>'>
                                                                        </asp:Label>
                                                                    </td>
                                                                </tr>
                                                                <tr>
                                                                    <td>Price Estimated
                                                                    </td>
                                                                    <td>
                                                                        <asp:Label runat="server" ID="PriceEstimatedNumericTextBox" Text='<%# Bind("POI_PriceEstimated") %>'>
                                                                        </asp:Label>
                                                                    </td>
                                                                </tr>
                                                                <tr>
                                                                    <td>Additional Costs
                                                                    </td>
                                                                    <td>
                                                                        <asp:Label runat="server" ID="AdditionalCostsNumericTextBox" Text='<%# Bind("POI_AdditionalCosts") %>'>
                                                                        </asp:Label>
                                                                    </td>
                                                                </tr>
                                                                <tr>
                                                                    <td>Explanation of Additional Costs
                                                                    </td>
                                                                    <td>
                                                                        <asp:Label runat="server" ID="ExplanationAdditionalCostsTextBox" Text='<%# Bind("POI_AdditionalCostsExplanation") %>'>
                                                                        </asp:Label>
                                                                    </td>
                                                                </tr>
                                                            </table>
                                                            <br />
                                                        </div>
                                                    </NestedViewTemplate>
                                                </MasterTableView>
                                            </telerik:RadGrid>
                                            <table>
                                                <tr>
                                                    <td>
                                                        <div>
                                                            <strong>Plus Sales Tax</strong>
                                                        </div>
                                                        <div>
                                                             <asp:Label runat="server" ID="PlusSalesTaxLabel" Text='<%# Bind("PO_PlusSalesTax") %>'>
                                                            </asp:Label>
                                                        </div>
                                                    </td>
                                                </tr>
                                                <tr>
                                                    <td>
                                                        <div>
                                                            <strong>Total Cost</strong>
                                                        </div>
                                                        <div>
                                                             <asp:Label runat="server" ID="TotalCostLabel" Text='<%# Bind("PO_TotalCost") %>'>
                                                            </asp:Label>
                                                        </div>
                                                    </td>
                                                </tr>
                                                <tr>
                                                    <td>
                                                        <div>
                                                            <strong>Supporting Documents</strong>
                                                        </div>
                                                        <asp:Panel runat="server" ID="supportingDocsPanel">
                                                              
                                                        </asp:Panel>
                                                    </td>
                                                </tr>
                                            </table>
                                            <asp:Button ID="btnUpdate" Text='<%# (Container is GridEditFormInsertItem) ? "Save" : "Update" %>'
                                                runat="server" CommandName='<%# (Container is GridEditFormInsertItem) ? "PerformInsert" : "Update" %>' UseSubmitBehavior="true" />
                                             <asp:Button ID="btnCancel" Text="Cancel" runat="server" CausesValidation="False"
                                                UseSubmitBehavior="false" CommandName="Cancel" />
                                        </FormTemplate>
                                    </EditFormSettings>
                                </MasterTableView>
                            </telerik:RadGrid>

1 Answer, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 28 Feb 2013, 04:43 AM
Hi,

Try the following code.
C#:
protected void RadGrid2_ItemDataBound(object sender, Telerik.Web.UI.GridItemEventArgs e)
{
  if (e.Item is GridEditFormItem && e.Item.IsInEditMode)
  {
     GridEditFormItem item = (GridEditFormItem)e.Item;
     Panel pnl = (Panel)item.FindControl("supportingDocsPanel");
  }
}

Thanks,
Shinu
Tags
Grid
Asked by
pmourfield
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Share this question
or