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

Problem referencing RadNumericTextBox within GridTemplateColumn through GridTableCell.Controls collection

1 Answer 100 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Andrew
Top achievements
Rank 1
Andrew asked on 11 Mar 2009, 11:26 PM
Hi,

I have a page that has a RadNumericTextBox as part of a GridTemplateColumn as specified below:

...
<telerik:GridTemplateColumn UniqueName="InvoiceAmount" HeaderText="Invoice Amount">
    <EditItemTemplate>
        <
table cellpadding="0" cellspacing="0"><tr><td>
            <
telerik:RadNumericTextBox EmptyMessage="Amount ..." Skin="Office2007" ShowSpinButtons="false" ButtonsPosition="Right" EnabledStyle-HorizontalAlign="Right" Type="Currency" Width="100" ID="rntbxInvoiceAmount" runat="server" Text='<%# Bind("Amount")%>' OnDataBinding="rntbxInvoiceAmount_DataBinding" onBlur="CalculateTotalInvoiceAmount()">
            
</telerik:RadNumericTextBox>
...

 
There is code in this pages base page that recurses the heirarchy of controls on the page at render time and makes "editable" controls non-visible and inserts label controls if the page is supposed to be readonly. The problem I'm seeing is that when the code gets to the GridTableCell control for the grid cell where the RadNumericTextBox should be, the GridTableCell.Controls collection is empty. I was expecting to have access to the RadNumericTextBox control instance at that point.
Should it work the way I am expecting it to, or is there a better way?

Thanks for any help you can give,
Andrew

1 Answer, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 12 Mar 2009, 07:26 AM
Hello Andrew,

You would have to access the EditFormCell instead of the GridTableCell as the RadNumericTextBox would be available only in the edit mode of the grid:
cs:
 protected void Button1_Click(object sender, EventArgs e) 
    { 
        foreach (GridEditableItem editedItem in RadGrid1.MasterTableView.GetItems(GridItemType.EditFormItem)) 
        { 
            Telerik.Web.UI.GridEditFormItem.EditFormTableCell cell = (Telerik.Web.UI.GridEditFormItem.EditFormTableCell)editedItem["InvoiceAmount"]; 
            foreach (Control ctrl in cell.Controls) 
            { 
                  // access the RadNumericTextBox here
            } 
        } 
    }  
 

Thanks
Princy.
Tags
Grid
Asked by
Andrew
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Share this question
or