FindControl problems

12 posts, 1 answers
  1. Orest
    Orest avatar
    10 posts
    Member since:
    Nov 2010

    Posted 19 Jan 2011 Link to this post

    Hi,

    I am having a hard time finding Control to a TextField nested within a radgrid and pageview. I am trying to access this textField inside of my Page_load Function.The TextField I am trying to get reference to is the TextBox ID="LongitudeTextBox"nested inside ( Radmultipage- RadView1 - RadGrid1 - MasterTableViewEditForm ).

    Previously I have gained control using the sender object from the form however in this case I do not have one since I am in the Page_Load function.
    I have tried multiple solutions to find control such as setting the sender object from the form to a global variable , or trying to nest findcontrol methods with the path described above.

    Any help would be greatly appreciated,

    Thank you.
  2. Marin
    Admin
    Marin avatar
    1057 posts

    Posted 20 Jan 2011 Link to this post

    Hello Orest,

     
    The Page_Load event is too early and the edit form has not been rendered yet if you have previously put the item in edit mode through clicking on the edit button. In order to access the controls in the edit form you should use the Page_PreRender event. First you need to get a reference to the grid, assuming that its RadView is the currently selected one, so that it is rendered on the page. Then then we get reference to the currently edited item and call findControl to get the desired control.

    GridItemType[] itemTypes = new GridItemType[]{GridItemType.EditFormItem};
    RadGrid1.MasterTableView.GetItems(itemTypes)[1].FindControl("TextBox8");

    Hope this helps. If I am missing something out, please provide some more details or a code sample showing the exact problem we can provide better assistance. 

    Regards,
    Marin
    the Telerik team
    Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.
  3. Orest
    Orest avatar
    10 posts
    Member since:
    Nov 2010

    Posted 20 Jan 2011 Link to this post

    <telerik:RadMultiPage ID="RadMultiPage1" runat="server"  Width="100%" SelectedIndex="0">
            <telerik:RadPageView ID="vwRouteList" runat="server">  
            <table>        
            <tr>
                <td style="width: 990px">   
                <table style="width:990px;"><tr><td>
                    <asp:Button ID="Button1" runat="server" Text="Export Data to Excel"
                        Width="150px" Font-Names="Tahoma" Font-Size="7pt" />
                     </td><td>  
                <strong><span style="font-size: 8pt; font-family: Tahoma">Update Sequence:</span></strong>
                <asp:Button ID="Button2" runat="server" Font-Names="Tahoma" Font-Size="7pt" Text="Update Sequence" Width="150px" /></td>                                   
                    <td>
                      <asp:CheckBox ID="chkIncludeStops" Font-Size="8pt" Font-Names="Tahoma" Font-Bold="true" Text="Include Temp Stops" runat="server" AutoPostBack="True" /> 
                 </td></tr></table>
                 </td>
            </tr>
       
            <tr>
            <td style="width: 990px">
                <telerik:RadGrid ID="RadGrid1" runat="server" AllowAutomaticInserts="True" AllowAutomaticUpdates="True" AllowFilteringByColumn="True" DataSourceID="GridViewDataSource" GridLines="None"
                    Skin="Telerik" Width="975px">
                    <MasterTableView AutoGenerateColumns="False" CommandItemDisplay="Top" DataKeyNames="LocationId,FullAddress"
                        DataSourceID="GridViewDataSource">
                        <Columns>
                            <telerik:GridBoundColumn DataField="LocationId" DataType="System.Decimal" HeaderText="LID"
                                ReadOnly="True" SortExpression="LocationId" UniqueName="LocationId" Display="False" AllowFiltering="False">
                            </telerik:GridBoundColumn>
                            <telerik:GridCheckBoxColumn DataField="Status" DataType="System.Boolean" HeaderText="Status"
                                SortExpression="Status" UniqueName="Status"  ShowFilterIcon="False">
                            </telerik:GridCheckBoxColumn>
                            <telerik:GridBoundColumn DataField="RouteID" DataType="System.Int32" HeaderText="RID"
                                SortExpression="RouteID" UniqueName="RouteID" Visible="False" AllowFiltering="False">
                            </telerik:GridBoundColumn>
                            <telerik:GridBoundColumn DataField="RSRouteID" DataType="System.Int32" HeaderText="RSRID"
                                SortExpression="RSRouteID" UniqueName="RSRouteID" Visible="False" AllowFiltering="False" >
                            </telerik:GridBoundColumn>
                            <telerik:GridBoundColumn DataField="DelivOrder" DataType="System.Decimal" HeaderText="Seq."
                                SortExpression="DelivOrder" UniqueName="DelivOrder" AllowFiltering="False">
                            </telerik:GridBoundColumn>
                            <telerik:GridCheckBoxColumn DataField="ReStock" DataType="System.Boolean" HeaderText="Restock Location"
                                SortExpression="ReStock" UniqueName="ReStock" Display="False" AllowFiltering="False">
                            </telerik:GridCheckBoxColumn>
                            <telerik:GridBoundColumn DataField="LocationName" HeaderText="LN" SortExpression="LocationName"
                                UniqueName="LocationName" AllowFiltering="False">
                            </telerik:GridBoundColumn>
                             
                             
                            <telerik:GridBoundColumn DataField="LocationType" HeaderText="LT" SortExpression="LocationType"
                                UniqueName="LocationType" Display="False" AllowFiltering="False">
                            </telerik:GridBoundColumn>
                             
                            <telerik:GridBoundColumn DataField="LocationTypeText" HeaderText="LT" SortExpression="LocationTypeText"
                                UniqueName="LocationTypeText" AllowFiltering="False">
                            </telerik:GridBoundColumn>
                             
                            <telerik:GridBoundColumn DataField="CategoryName" HeaderText="Cat" SortExpression="CategoryName"
                                UniqueName="CategoryName" AllowFiltering="False">
                            </telerik:GridBoundColumn>
                             
                            <telerik:GridBoundColumn DataField="Address" HeaderText="Addr" SortExpression="Address"
                                UniqueName="Address" AllowFiltering="False">
                            </telerik:GridBoundColumn>
                            <telerik:GridBoundColumn DataField="Longitude" DataType="System.Double" HeaderText="Longitude"
                                SortExpression="Longitude" UniqueName="Longitude" Display="False" AllowFiltering="False">
                            </telerik:GridBoundColumn>
                            <telerik:GridBoundColumn DataField="Latitude" DataType="System.Double" HeaderText="Latitude"
                                SortExpression="Latitude" UniqueName="Latitude" Display="False" AllowFiltering="False">
                            </telerik:GridBoundColumn>
                            <telerik:GridBoundColumn DataField="City" HeaderText="City" SortExpression="City" UniqueName="City" AllowFiltering="False">
                            </telerik:GridBoundColumn>
                            <telerik:GridBoundColumn DataField="State" HeaderText="State" SortExpression="State"
                                UniqueName="State" Display="False" AllowFiltering="False">
                            </telerik:GridBoundColumn>
                            <telerik:GridBoundColumn DataField="Zip" HeaderText="Zip" SortExpression="Zip" UniqueName="Zip" AllowFiltering="False">
                            </telerik:GridBoundColumn>
                            <telerik:GridBoundColumn DataField="Phone1" HeaderText="Phone1" SortExpression="Phone1" AllowFiltering="False"
                                UniqueName="Phone1" Display="False">
                            </telerik:GridBoundColumn>
                            <telerik:GridBoundColumn DataField="Notes" HeaderText="Notes" SortExpression="Notes" AllowFiltering="False"
                                UniqueName="Notes" Display="False">
                            </telerik:GridBoundColumn>
                            <telerik:GridBoundColumn DataField="StartDate" DataType="System.DateTime" HeaderText="StartDate"
                                SortExpression="StartDate" UniqueName="StartDate" Display="False" AllowFiltering="False">
                            </telerik:GridBoundColumn>
                            <telerik:GridBoundColumn DataField="StopDate" DataType="System.DateTime" HeaderText="StopDate"
                                SortExpression="StopDate" UniqueName="StopDate" Display="False" AllowFiltering="False">
                            </telerik:GridBoundColumn>
                            <telerik:GridBoundColumn DataField="Draw" DataType="System.Decimal" HeaderText="Draw"
                                SortExpression="Draw" UniqueName="Draw" AllowFiltering="False">
                            </telerik:GridBoundColumn>
                            <telerik:GridBoundColumn DataField="ReDraw" DataType="System.Decimal" HeaderText="Re-Stock"
                                SortExpression="ReDraw" UniqueName="ReDraw" AllowFiltering="False">
                            </telerik:GridBoundColumn>
                            <telerik:GridCheckBoxColumn DataField="Graffiti" DataType="System.Boolean" HeaderText="Graffiti"
                                SortExpression="Graffiti" UniqueName="Graffiti" Display="False" AllowFiltering="False">
                            </telerik:GridCheckBoxColumn>
                            <telerik:GridCheckBoxColumn DataField="Dented" DataType="System.Boolean" HeaderText="Dented"
                                SortExpression="Dented" UniqueName="Dented" Display="False" AllowFiltering="False">
                            </telerik:GridCheckBoxColumn>
                            <telerik:GridCheckBoxColumn DataField="LockDraw" DataType="System.Boolean" HeaderText="LockDraw"
                                SortExpression="LockDraw" UniqueName="LockDraw" Display="False" AllowFiltering="False">
                            </telerik:GridCheckBoxColumn>
                            <telerik:GridBoundColumn DataField="DriverMemo" HeaderText="DriverMemo" SortExpression="DriverMemo"
                                UniqueName="DriverMemo" Display="False" AllowFiltering="False">
                            </telerik:GridBoundColumn>
                            <telerik:GridBoundColumn DataField="RackName" HeaderText="RackName" SortExpression="RackName"
                                UniqueName="RackName" Display="False" AllowFiltering="False">
                            </telerik:GridBoundColumn>
                            <telerik:GridBoundColumn DataField="CityAreaID" HeaderText="CityAreaID" SortExpression="CityAreaID"
                                UniqueName="CityAreaID" Display="False" AllowFiltering="False">
                            </telerik:GridBoundColumn>
                            <telerik:GridHyperLinkColumn DataNavigateUrlFields="LocationID" DataTextFormatString="<img src=../../../Images/pencil-icon.gif />" DataNavigateUrlFormatString="~/RegisteredUsers/CircTools/Locations/EditLocationForm.aspx?LocationID={0}"
                                Target="_blank" Text="<img border=0 src=../../../Images/pencil-icon.gif />" UniqueName="column2" AllowFiltering="False">
                                <FooterStyle HorizontalAlign="Left" Wrap="False" />
                                <HeaderStyle HorizontalAlign="Left" Wrap="False" />
                                <ItemStyle HorizontalAlign="Left" Wrap="False" />
                            </telerik:GridHyperLinkColumn>
                            <telerik:GridHyperLinkColumn DataNavigateUrlFields="LocationID" DataTextFormatString="<img src=../../../Images/chart-icon.gif />" DataNavigateUrlFormatString="~/RegisteredUsers/CircTools/Locations/LocationPerformance.aspx?LocationID={0}"
                                Target="_blank" Text="<img border=0 src=../../../Images/chart-icon.gif />" UniqueName="column1" AllowFiltering="False">
                                <FooterStyle HorizontalAlign="Left" Wrap="False" />
                                <HeaderStyle HorizontalAlign="Left" Wrap="False" />
                                <ItemStyle HorizontalAlign="Left" Wrap="False" />
                            </telerik:GridHyperLinkColumn>
                            <telerik:GridHyperLinkColumn DataNavigateUrlFields="FullAddress,LocationName" DataTextFormatString="<img src=../../../Images/world_info_16 />" DataNavigateUrlFormatString="http://maps.google.com/m?q=={0}"
                                Target="_blank" Text="<img border=0 src=../../../Images/world_info_16.gif />" UniqueName="column" AllowFiltering="False">
                                <FooterStyle HorizontalAlign="Left" Wrap="False" />
                                <HeaderStyle HorizontalAlign="Left" Wrap="False" />
                                <ItemStyle HorizontalAlign="Left" Wrap="False" />
                            </telerik:GridHyperLinkColumn>
                        </Columns>
                        <EditFormSettings EditFormType="Template">
                            <FormTemplate>
                                <table style="width: 800px">
                                    <tr>
                                        <td style="width: 100px">
                                            <asp:Button ID="btnUpdate" Text='<%# IIf((TypeOf(Container) is GridEditFormInsertItem), "Insert", "Update") %>'
                                    runat="server" CommandName='<%# IIf((TypeOf(Container) is GridEditFormInsertItem), "PerformInsert", "Update")%>' Font-Names="Tahoma" Font-Size="8pt" Width="100px">
                                </asp:Button>
                                        </td>
                                        <td style="width: 100px">
                                            <asp:Button ID="btnCancel" Text="Cancel" runat="server" CausesValidation="False"
                                            CommandName="Cancel" Font-Names="Tahoma" Font-Size="8pt" Width="100px"></asp:Button></td>
                                        <td style="width: 25px">
                                        </td>
                                        <td style="width: 100px">
                                            </td>
                                        <td style="width: 100px">
                                            </td>
                                    </tr>
                                </table>
                                <table cellpadding="5" style="width: 970px">
                                    <tr>
                                        <td style="border-top-width: 1px; border-left-width: 1px; border-left-color: lime;
                                            border-bottom-width: 1px; border-bottom-color: lime; width: 300px; border-top-color: lime;
                                            border-right-width: 1px; border-right-color: lime" valign="top">
                                            <table cellpadding="5" style="border-right: #63ad39 1px solid; border-top: #63ad39 1px solid; border-left: #63ad39 1px solid; width: 300px;
                                                border-bottom: #63ad39 1px solid;">
                                                <tr>
                                                    <td colspan="2" style="background-image: url(../../../Images/CellBkgrd.gif)">
                                                        Location Information</td>
                                                </tr>
                                                <tr>
                                                    <td style="width: 125px">
                                                        <asp:Label ID="LocationIdLabel1" runat="server" Font-Names="Tahoma" Font-Size="8pt"
                                                            Text='<%# Eval("LocationId") %>' Width="150px"></asp:Label></td>
                                                    <td style="width: 125px">
                                                        <span>Location ID:</span></td>
                                                </tr>
                                                <tr>
                                                    <td style="width: 125px; text-align: center">
                                                        <asp:CheckBox ID="StatusCheckBox" runat="server" Checked='<%# Bind("Status") %>'
                                                            Font-Names="Tahoma" Font-Size="8pt" /></td>
                                                    <td style="width: 125px">
                                                        <span>Status:</span></td>
                                                </tr>
                                                <tr>
                                                    <td style="width: 125px">
                                                        <telerik:RadComboBox ID="RadComboBox1" runat="server" DataSourceID="RouteDataSource"
                                                            DataTextField="RouteName" DataValueField="RouteID" SelectedValue='<%# Bind("RouteID") %>'>
                                                        </telerik:RadComboBox>
                                                    </td>
                                                    <td style="width: 125px">
                                                        <span>Route ID:</span></td>
                                                </tr>
                                                <tr>
                                                    <td style="width: 125px">
                                                        <telerik:RadComboBox ID="RadComboBox7" runat="server" DataSourceID="RSRouteDataSource"
                                                            DataTextField="RouteName" DataValueField="RSRouteID" SelectedValue='<%# Bind("RSRouteID") %>'>
                                                        </telerik:RadComboBox>
                                                    </td>
                                                    <td style="width: 125px">
                                                        Restock Route ID:</td>
                                                </tr>
                                                <tr>
                                                    <td style="width: 125px">
                                                        <asp:TextBox ID="LocationNameTextBox" runat="server" Font-Names="Tahoma" Font-Size="8pt"
                                                            Text='<%# Bind("LocationName") %>' TextMode="MultiLine" Width="150px"></asp:TextBox></td>
                                                    <td style="width: 125px">
                                                        <span>Location Name:</span></td>
                                                </tr>
                                                <tr>
                                                    <td style="width: 125px">
                                                        <telerik:RadComboBox ID="RadComboBox2" runat="server" DataSourceID="LocationTypeDataSource"
                                                            DataTextField="LocationType" DataValueField="LocationTypeID" SelectedValue='<%# Bind("LocationType") %>'>
                                                        </telerik:RadComboBox>
                                                    </td>
                                                    <td style="width: 125px; color: #000000">
                                                        <span>Location Type:</span></td>
                                                </tr>
                                                <tr>
                                                    <td style="width: 125px">
                                                        <telerik:RadComboBox ID="RadComboBox3" runat="server" DataSourceID="CategoryDataSource"
                                                            DataTextField="CategoryName" DataValueField="CategoryID" SelectedValue='<%# Bind("Category") %>'>
                                                        </telerik:RadComboBox>
                                                    </td>
                                                    <td style="width: 125px; color: #000000">
                                                        <span>Subcategory:</span></td>
                                                </tr>
                                                <tr>
                                                    <td style="width: 125px">
                                                        <asp:TextBox ID="DelivOrderTextBox" runat="server" Font-Names="Tahoma" Font-Size="8pt"
                                                            Text='<%# Bind("DelivOrder") %>' Width="150px"></asp:TextBox></td>
                                                    <td style="width: 125px">
                                                        <span>Sequence:</span></td>
                                                </tr>
                                                <tr>
                                                    <td style="width: 125px">
                                                        <telerik:RadDatePicker ID="RadDatePicker1" runat="server" Culture="English (United States)"
                                                            DbSelectedDate='<%# Bind("StartDate") %>' Skin="Telerik" Width="150px">
                                                            <Calendar Skin="Telerik" UseColumnHeadersAsSelectors="False" UseRowHeadersAsSelectors="False" runat="server"
                                                                ViewSelectorText="x">
                                                            </Calendar>
                                                            <DatePopupButton HoverImageUrl="" ImageUrl="" />
                                                            <DateInput DateFormat="M/d/yyyy" DisplayDateFormat="M/d/yyyy">
                                                            </DateInput>
                                                        </telerik:RadDatePicker>
                                                    </td>
                                                    <td style="font-size: 8pt; width: 125px; font-family: Tahoma">
                                                        <span>Start Date:</span></td>
                                                </tr>
                                                <tr style="font-size: 8pt; font-family: Tahoma">
                                                    <td style="width: 125px">
                                                        <telerik:RadDatePicker ID="RadDatePicker2" runat="server" Culture="English (United States)"
                                                            DbSelectedDate='<%# Bind("StopDate") %>' Skin="Telerik" Width="150px">
                                                            <Calendar Skin="Telerik" UseColumnHeadersAsSelectors="False" UseRowHeadersAsSelectors="False" runat="server"
                                                                ViewSelectorText="x">
                                                            </Calendar>
                                                            <DatePopupButton HoverImageUrl="" ImageUrl="" />
                                                            <DateInput DateFormat="M/d/yyyy" DisplayDateFormat="M/d/yyyy">
                                                            </DateInput>
                                                        </telerik:RadDatePicker>
                                                    </td>
                                                    <td style="width: 125px">
                                                        <span>End Date:</span></td>
                                                </tr>
                                                <tr style="font-size: 8pt; font-family: Tahoma">
                                                    <td style="width: 125px">
                                                        <asp:TextBox ID="ReasonStoppedTextBox" runat="server" Font-Names="Tahoma" Font-Size="8pt"
                                                            Text='<%# Bind("ReasonStopped") %>' Width="150px"></asp:TextBox></td>
                                                    <td style="width: 125px">
                                                        <span>Reason Stopped:</span></td>
                                                </tr>
                                                <tr style="font-size: 8pt; font-family: Tahoma">
                                                    <td style="width: 125px; text-align: center">
                                                        <asp:CheckBox ID="InsideOutsideCheckBox" runat="server" Checked='<%# Bind("InsideOutside") %>'
                                                            Font-Names="Tahoma" Font-Size="8pt" /></td>
                                                    <td style="width: 125px">
                                                        <span>Inside/Outside</span></td>
                                                </tr>
                                                <tr style="font-size: 8pt; font-family: Tahoma">
                                                    <td style="width: 125px">
                                                        <asp:TextBox ID="TimeOpenTextBox" runat="server" Font-Names="Tahoma" Font-Size="8pt"
                                                            Text='<%# Bind("TimeOpen") %>' Width="150px"></asp:TextBox></td>
                                                    <td style="width: 125px">
                                                        <span>Time Open:</span></td>
                                                </tr>
                                                   <!----->
                                            <tr style="font-size: 8pt; font-family: Tahoma">
                                                <td style="width: 125px; text-align: center">
                                                     <asp:CheckBox ID="chkTempStop" runat="server" Checked='<%#  Bind("TempStop") %>'
                                                        Font-Names="Tahoma" Font-Size="8pt" />
                                                 </td>
                                                <td style="width: 125px">
                                                    <span><strong>Temp Stop:</strong></span></td>
                                            </tr>
                                            <tr style="font-size: 8pt; font-family: Tahoma">
                                                <td style="width: 125px">
                                                    <telerik:RadDatePicker ID="rdDtReStDt" runat="server" Culture="English (United States)"
                                                        DbSelectedDate='<%# Bind("ReStartDate") %>' Skin="Telerik" Width="150px">
                                                        <Calendar Skin="Telerik" UseColumnHeadersAsSelectors="False" UseRowHeadersAsSelectors="False"
                                                            ViewSelectorText="x">
                                                        </Calendar>
                                                        <DatePopupButton HoverImageUrl="" ImageUrl="" />
                                                        <DateInput DateFormat="M/d/yyyy" DisplayDateFormat="M/d/yyyy">
                                                        </DateInput>
                                                    </telerik:RadDatePicker>
                                                 </td>
                                                <td style="width: 125px">
                                                    <span><strong>Re Start Date:</strong></span></td>
                                            </tr>
                                            <tr style="font-size: 8pt; font-family: Tahoma">
                                                <td style="width: 125px">
                                                    <telerik:RadDatePicker ID="RdDtTempStopDt" runat="server" Culture="English (United States)"
                                                        DbSelectedDate='<%# Bind("TempStopDate") %>' Skin="Telerik" Width="150px">
                                                        <Calendar Skin="Telerik" UseColumnHeadersAsSelectors="False" UseRowHeadersAsSelectors="False"
                                                            ViewSelectorText="x">
                                                        </Calendar>
                                                        <DatePopupButton HoverImageUrl="" ImageUrl="" />
                                                        <DateInput DateFormat="M/d/yyyy" DisplayDateFormat="M/d/yyyy">
                                                        </DateInput>
                                                    </telerik:RadDatePicker>
                                                    </td>
                                                <td style="width: 125px">
                                                    <span><strong>Temp Stop Date:</strong></span></td>
                                            </tr>
                                            <!---->
                                            </table>
                                            <br />
                                            <table cellpadding="5" style="border-right: #63ad39 1px solid; border-top: #63ad39 1px solid; border-left: #63ad39 1px solid; width: 300px;
                                                border-bottom: #63ad39 1px solid;">
                                                <tr>
                                                    <td colspan="2" style="background-image: url(../../../Images/CellBkgrd.gif)">
                                                        Audit Information</td>
                                                </tr>
                                                <tr>
                                                    <td style="width: 100px; text-align: center">
                                                        <asp:CheckBox ID="GraffitiCheckBox" runat="server" Checked='<%# Bind("Graffiti") %>' /></td>
                                                    <td style="width: 100px">
                                                        <span>Graffiti:</span></td>
                                                </tr>
                                                <tr>
                                                    <td style="width: 100px; text-align: center">
                                                        <asp:CheckBox ID="DentedCheckBox" runat="server" Checked='<%# Bind("Dented") %>' /></td>
                                                    <td style="width: 100px">
                                                        <span style="font-size: 8pt; font-family: Tahoma"><strong>Dented:</strong></span></td>
                                                </tr>
                                                <tr>
                                                    <td style="width: 100px; text-align: center;"><asp:CheckBox ID="PermitCheckBox" runat="server" Checked='<%# Bind("Permit") %>' /></td>
                                                    <td style="width: 100px">
                                                        <span style="font-size: 8pt; font-family: Tahoma"><strong>Permit:</strong></span></td>
                                                </tr>
                                                <tr>
                                                    <td style="width: 100px">
                                                        <asp:TextBox ID="TextBox1" runat="server" Text='<%# Bind("BusStop") %>' Width="150px"></asp:TextBox></td>
                                                    <td style="width: 100px">
                                                        <span style="font-size: 8pt; font-family: Tahoma"><strong>Bus Stop:</strong></span></td>
                                                </tr>
                                                <tr>
                                                    <td style="width: 100px">
                                                    </td>
                                                    <td style="width: 100px">
                                                        <span style="font-size: 8pt; font-family: Tahoma"><strong>Competition:</strong></span></td>
                                                </tr>
                                            </table>
                                        </td>
                                        <td style="border-top-width: 1px; border-left-width: 1px; border-left-color: lime;
                                            border-bottom-width: 1px; border-bottom-color: lime; width: 300px; border-top-color: lime;
                                            border-right-width: 1px; border-right-color: lime" valign="top">
                                            <table cellpadding="5" style="border-right: #63ad39 1px solid; border-top: #63ad39 1px solid;
                                                border-left: #63ad39 1px solid; width: 300px; border-bottom: #63ad39 1px solid">
                                                <tr>
                                                    <td colspan="2" style="background-image: url(../../../Images/CellBkgrd.gif)">
                                                        Address Information</td>
                                                </tr>
                                                <tr>
                                                    <td style="width: 125px">
                                                        <asp:TextBox ID="AddressTextBox" runat="server" Font-Names="Tahoma" Font-Size="8pt"
                                                            Height="50px" Text='<%# Bind("Address") %>' TextMode="MultiLine" Width="150px"></asp:TextBox></td>
                                                    <td style="width: 125px">
                                                        <span style="font-size: 8pt; font-family: Tahoma"><strong>Address:</strong></span></td>
                                                </tr>
                                                <tr>
                                                    <td style="width: 125px; height: 31px">
                                                        <asp:TextBox ID="CityTextBox" runat="server" Font-Names="Tahoma" Font-Size="8pt"
                                                            Text='<%# Bind("City") %>' Width="150px"></asp:TextBox></td>
                                                    <td style="width: 125px; height: 31px">
                                                        <span style="font-size: 8pt; font-family: Tahoma"><strong>City:</strong></span></td>
                                                </tr>
                                                <tr>
                                                    <td style="width: 125px">
                                                        <asp:TextBox ID="StateTextBox" runat="server" Font-Names="Tahoma" Font-Size="8pt"
                                                            Text='<%# Bind("State") %>' Width="150px"></asp:TextBox></td>
                                                    <td style="width: 125px">
                                                        <span style="font-size: 8pt; font-family: Tahoma"><strong>Sate/Prov:</strong></span></td>
                                                </tr>
                                                <tr>
                                                    <td style="width: 125px">
                                                        <asp:TextBox ID="ZipTextBox" runat="server" Font-Names="Tahoma" Font-Size="8pt" Text='<%# Bind("Zip") %>'
                                                            Width="150px"></asp:TextBox></td>
                                                    <td style="width: 125px">
                                                        <span style="font-size: 8pt; font-family: Tahoma"><strong>Zip/FSA:</strong></span></td>
                                                </tr>
                                                <tr>
                                                    <td style="width: 125px">
                                                        <telerik:RadComboBox ID="RadComboBox4" runat="server" DataSourceID="CityAreaDataSource"
                                                            DataTextField="CityAreaName" DataValueField="CityAreaID" SelectedValue='<%# Bind("CityAreaID") %>'>
                                                        </telerik:RadComboBox>
                                                    </td>
                                                    <td style="width: 125px">
                                                        <span style="font-size: 8pt; font-family: Tahoma"><strong>City Area:</strong></span></td>
                                                </tr>
                                                <tr>
                                                    <td style="width: 125px">
                                                        <telerik:RadComboBox ID="RadComboBox5" runat="server" DataSourceID="CommunityDataSource"
                                                            DataTextField="CommunityName" DataValueField="Community" SelectedValue='<%# Bind("Community") %>'>
                                                        </telerik:RadComboBox>
                                                    </td>
                                                    <td style="width: 125px">
                                                        <span style="font-size: 8pt; font-family: Tahoma"><strong>Community:</strong></span></td>
                                                </tr>
                                                <tr>
                                                    <td style="width: 125px">
                                                        <asp:TextBox ID="LatitudeTextBox" runat="server" Font-Names="Tahoma" Font-Size="8pt"
                                                            Text='<%# Bind("Latitude") %>' Width="150px"></asp:TextBox></td>
                                                    <td style="width: 125px">
                                                        <span style="font-size: 8pt; font-family: Tahoma"><strong>Latitude:</strong></span></td>
                                                </tr>
                                                <tr>
                                                    <td style="width: 125px">
                                                        <asp:TextBox ID="LongitudeTextBox" runat="server" Font-Names="Tahoma" Font-Size="8pt"
                                                            Text='<%# Bind("Longitude") %>' OnDatabinding = "LongitudeTextBox1_GetSession" Width="150px"></asp:TextBox></td>
                                                    <td style="width: 125px">
                                                        <span style="font-size: 8pt; font-family: Tahoma"><strong>Longitude:</strong></span></td>
                                                </tr>
    the Code Above is the .aspx page. I am trying to get control to the LongitudeTextBox and write text o it with a session variable when the page is loaded. I am doing my Code behind in VB.net.

    Thank you for the help.
  4. Marin
    Admin
    Marin avatar
    1057 posts

    Posted 21 Jan 2011 Link to this post

    Hello Orest,

    The problem with finding the control on Page_Load event is that when the grid is first initialized it still does not have items on Page_Load, additionally in order to access the control the item has to be in edit mode (otherwise the textbox is not rendered and not visible). Having this in mind the only scenario that we will be able to find the textbox in Page_Load will be after we have loaded the EditForm and we press the Update button then on going through the Page_Load event we can access the TextBox. So the code snippet could look like this, with additional checks whether we have items in the grid and the edit form has been initialized:

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs)
            If RadGrid1.MasterTableView.Items.Count > 0 AndAlso RadGrid1.MasterTableView.Items(0).EditFormItem.EditFormCell.Controls.Count > 0 Then
                Dim longitudeTextBox As TextBox = TryCast(RadGrid1.MasterTableView.Items(0).EditFormItem.EditFormCell.FindControl("LongitudeTextBox"), TextBox)
            End If
        End Sub

    If you need to access the textbox earlier you should pick another event such as ItemCreated or ItemDataBound in the grid.

    All the best,
    Marin
    the Telerik team
    Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.
  5. Orest
    Orest avatar
    10 posts
    Member since:
    Nov 2010

    Posted 21 Jan 2011 Link to this post

    Unfortunately that is also not working. Is there any way that I could have the Text box be populated with a session variable every time it is created?
    This would also solve my problem.
  6. Marin
    Admin
    Marin avatar
    1057 posts

    Posted 24 Jan 2011 Link to this post

    Hello Orest,

    You can use the ItemDataBound event to set the text of the textbox to any new value you want. Here is a code snippet:

    Protected Sub RadGrid1_ItemDataBound(sender As Object, e As GridItemEventArgs)
        If TypeOf e.Item Is GridEditableItem AndAlso e.Item.IsInEditMode Then
            Dim editItem As GridEditableItem = TryCast(e.Item, GridEditableItem)
            Dim txb As TextBox = TryCast(editItem.FindControl("LongitudeTextBox"), TextBox)
            'set text to some new value
            txb.Text = "12345"
        End If
    End Sub

    Greetings,
    Marin
    the Telerik team
    Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.
  7. Orest
    Orest avatar
    10 posts
    Member since:
    Nov 2010

    Posted 25 Jan 2011 Link to this post

    Sorry but I was wondering if i could approach this problem from a different angle.

    Would it be possible if I opened an aspx page inside of a RadWindow from the edit form.Then copy  a value that was calculated in that child window to a TextBox in the Parent window?

    this would solve my problem of not knowing when the control in the EditForm is created because you would need to have the form open to get to the RadWindow.

    Thank you,
  8. Marin
    Admin
    Marin avatar
    1057 posts

    Posted 25 Jan 2011 Link to this post

    Hi Orest,

     Yes, it is possible to achieve this. 
    You can use javascript to copy the values from the window to the main page. For this purpose you can handle the OnClientClose event of the window and access the values there as shown in this live demo. Of course you will still need to find client-side the actual textbox that you need to set the values to. If you need to implement grid editing with window you can follow the approach shown in this demo.

    On additional note, the controls in the edit form are expectedly created only after the grid item has been put in edit mode (i.e we have pressed the edit) and the edit form has been initialized. Then on postback follows the standard page life cycle where on Page_Load the controls (including those in the edit form) are initialized and after the OnDataBound they are filled with data (that is why I used the ItemDataBound event in the previous post to reset the value of the textbox).

    Hope this helps.

    All the best,
    Marin
    the Telerik team
    Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.
  9. Orest
    Orest avatar
    10 posts
    Member since:
    Nov 2010

    Posted 26 Jan 2011 Link to this post

    Since I decided to follow the code linked above. is there an easy way of accessing the control for the LongitudeTextbox since I know the editform will be opened when the popup window is called?

  10. Marin
    Admin
    Marin avatar
    1057 posts

    Posted 26 Jan 2011 Link to this post

    Hi Orest,

     If we follow the structure of the demo about the window editing it has a separate page (EditForm.aspx) that is loaded and shown in the window. Depending on the contents of this page you can freely access its elements in the code behind for the EditForm.aspx. Meaning that if you have a textbox there called LongitudeTextbox, you can access it in the EditForm page simply by its id: 

    LongitudeTextbox.Text="value"

    All the best,
    Marin
    the Telerik team
    Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.
  11. Orest
    Orest avatar
    10 posts
    Member since:
    Nov 2010

    Posted 27 Jan 2011 Link to this post

    Thank you Very much for the help I have nearly completed all that I want to do however I seem to be getting some weird bug

    when finding controls on the page I am using the following code:
    var masterTable = $find("<%=RadGrid1.ClientID%>").get_masterTableView();
                   var txb = $telerik.$(masterTable.get_element()).find('input[id*="CityTextBox"]')[0];
                    City =  txb.value;
           masterTable = $find("<%=RadGrid1.ClientID%>").get_masterTableView();
                    txb = $telerik.$(masterTable.get_element()).find('input[id*="ZipTextBox"]')[0];
                    Zip =  txb.value;
                    
          masterTable = $find("<%=RadGrid1.ClientID%>").get_masterTableView();
                    txb = $telerik.$(masterTable.get_element()).find('input[id*="AddressTextBox"]')[0];
                    Street =  txb.value;

    I get an error on when trying to use the Street  = txb.value;
    Error: 'value' is null or not an object.
    This is a strange error considering the CityTextBox and ZipTextBox both work when I do not include the final find()
    All Textbox`s are located on the same form and in the same table
    </table>
                                           </td>
                                           <td style="border-top-width: 1px; border-left-width: 1px; border-left-color: lime;
                                               border-bottom-width: 1px; border-bottom-color: lime; width: 300px; border-top-color: lime;
                                               border-right-width: 1px; border-right-color: lime" valign="top">
                                               <table cellpadding="5" style="border-right: #63ad39 1px solid; border-top: #63ad39 1px solid;
                                                   border-left: #63ad39 1px solid; width: 300px; border-bottom: #63ad39 1px solid">
                                                   <tr>
                                                       <td colspan="2" style="background-image: url(../../../Images/CellBkgrd.gif)">
                                                           Address Information</td>
                                                   </tr>
                                                   <tr>
                                                       <td style="width: 125px">
                                                           <asp:TextBox ID="AddressTextBox" runat="server" Font-Names="Tahoma" Font-Size="8pt"
                                                               Height="50px" Text='<%# Bind("Address") %>' TextMode="MultiLine" Width="150px"></asp:TextBox></td>
                                                       <td style="width: 125px">
                                                           <span style="font-size: 8pt; font-family: Tahoma"><strong>Address:</strong></span></td>
                                                   </tr>
                                                   <tr>
                                                       <td style="width: 125px; height: 31px">
                                                           <asp:TextBox ID="CityTextBox" runat="server" Font-Names="Tahoma" Font-Size="8pt"
                                                               Text='<%# Bind("City") %>' Width="150px"></asp:TextBox></td>
                                                       <td style="width: 125px; height: 31px">
                                                           <span style="font-size: 8pt; font-family: Tahoma"><strong>City:</strong></span></td>
                                                   </tr>
                                                   <tr>
                                                       <td style="width: 125px">
                                                           <asp:TextBox ID="StateTextBox" runat="server" Font-Names="Tahoma" Font-Size="8pt"
                                                               Text='<%# Bind("State") %>' Width="150px"></asp:TextBox></td>
                                                       <td style="width: 125px">
                                                           <span style="font-size: 8pt; font-family: Tahoma"><strong>Sate/Prov:</strong></span></td>
                                                   </tr>
                                                   <tr>
                                                       <td style="width: 125px">
                                                           <asp:TextBox ID="ZipTextBox" runat="server" Font-Names="Tahoma" Font-Size="8pt" Text='<%# Bind("Zip") %>'
                                                               Width="150px"></asp:TextBox></td>
                                                       <td style="width: 125px">
                                                           <span style="font-size: 8pt; font-family: Tahoma"><strong>Zip/FSA:</strong></span></td>
                                                   </tr>
                                                   <tr>
                                                       <td style="width: 125px">
                                                           <telerik:RadComboBox ID="RadComboBox4" runat="server" DataSourceID="CityAreaDataSource"
                                                               DataTextField="CityAreaName" DataValueField="CityAreaID" SelectedValue='<%# Bind("CityAreaID") %>'>
                                                           </telerik:RadComboBox>
                                                       </td>
                                                       <td style="width: 125px">
                                                           <span style="font-size: 8pt; font-family: Tahoma"><strong>City Area:</strong></span></td>
                                                   </tr>
                                                   <tr>
                                                       <td style="width: 125px">
                                                           <telerik:RadComboBox ID="RadComboBox5" runat="server" DataSourceID="CommunityDataSource"
                                                               DataTextField="CommunityName" DataValueField="Community" SelectedValue='<%# Bind("Community") %>'>
                                                           </telerik:RadComboBox>
                                                       </td>
                                                       <td style="width: 125px">
                                                           <span style="font-size: 8pt; font-family: Tahoma"><strong>Community:</strong></span></td>
                                                   </tr>
                                                   <tr>
                                                       <td style="width: 125px; height: 31px;">
                                                           <asp:TextBox ID="LatitudeTextBox" runat="server" Font-Names="Tahoma" Font-Size="8pt"
                                                               Text='<%# Bind("Latitude") %>' Width="150px"></asp:TextBox></td>
                                                       <td style="width: 125px; height: 31px;">
                                                           <span style="font-size: 8pt; font-family: Tahoma"><strong>Latitude:</strong></span></td>
                                                   </tr>
                                                   <tr>
                                                       <td style="width: 125px">
                                                           <asp:TextBox ID="LongitudeTextBox" runat="server" Font-Names="Tahoma" Font-Size="8pt"
                                                               Text='<%# Bind("Longitude") %>' OnDatabinding = "LongitudeTextBox1_GetSession" Width="150px"></asp:TextBox></td>
                                                       <td style="width: 125px">
                                                           <span style="font-size: 8pt; font-family: Tahoma"><strong>Longitude:</strong></span></td>
                                                   </tr>
                                               </table>

           
  12. Answer
    Marin
    Admin
    Marin avatar
    1057 posts

    Posted 28 Jan 2011 Link to this post

    Hi Orest,

    The problem is that for the AddressTextBox you have set TextMode="MultiLine". This causes the textbox to be rendered as textarea instead of input element. You can change the code like this:

    txb = $telerik.$(masterTable.get_element()).find('textarea[id*="AddressTextBox"]')[0];

    Regards,
    Marin
    the Telerik team
    Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.
Back to Top