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

RadTabStrip with UserControls within FormTemplate.

4 Answers 144 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Jon
Top achievements
Rank 1
Jon asked on 13 Oct 2010, 07:21 PM
I have a RadGrid that has within it a RadTabStrip (which is within the FormTemplate of the EditFormSettings). For each tab, I have a user control that contains the fields I want the user to interact with. These user controls have (Microsoft) ListBox and DropDownList controls and bind themselves to their own data to populate each of these controls with the possible values and this all works fine. The RadGrid properly populates the textbox values of the tab when the user clicks Edit (GridEditColumn) using values from the database. However, I need to update the RadTab's user control DropDownList/ListBox with the selections from the database, but how do I access the User Control (or these child controls) within the RadTab? I can't seem to catch any of the RadTabStrip events to do this (I'm guessing that these aren't being bubbled up to the grid's level?) and I haven't been able to use FindControl to locate the friendly control names (I know I could use ugly names like ctl00_ctl14_ctl00, but this is way too brittle :) ). 

The user control within each RadTab does all it's databinding events first, so all the controls are loaded with data. I'm thinking the DataBound event for the Grid is the right place to start, since this is the last visible event I've found after clicking Edit (before the RadTab is rendered -- other than perhaps PreRender, but then I have to walk the UI control tree).

Am I nesting things too deep here? Is there any easier/better way to approach this? Basically, I'm trying to have a RadTabStrip for editing a grid row's (detailed) data (not just the fields I show in the row). I don't think the updating will be an issue (updating already works for propagating textbox/checkbox values to the database), since I have access to the control tree through the ItemCommand event handler for the Update event.

Here's the markup snippet:
<%@ Register Src="~/Views/UserControls/AccountInfo.ascx" TagName="AccountInfo"
    TagPrefix="dd" %>
<%@ Register Src="~/Views/UserControls/AddressInfo.ascx" TagName="AddressInfo" TagPrefix="dd" %>
<%@ Register Src="~/Views/UserControls/RoleInfo.ascx" TagName="RoleInfo" TagPrefix="dd" %>
  
<telerik:RadGrid ID="GridUser" AllowSorting="True" PageSize="10" AutoGenerateColumns="false"
        ItemStyle-Font-Size="11px" AlternatingItemStyle-Font-Size="11px" AllowPaging="True"
        AllowFilteringByColumn="true" PagerStyle-AlwaysVisible="true" AllowMultiRowSelection="False"
        runat="server" Width="700px" Skin="Office2007" HeaderStyle-CssClass="RadGridHeader"
        DataSourceID="MasterDataSource" ShowGroupPanel="true" 
        AllowAutomaticInserts="True" AllowAutomaticUpdates="True">
        <MasterTableView Name="GridUserView" DataSourceID="MasterDataSource" DataKeyNames="ID" Width="100%"
            Summary="RadGrid table" CommandItemDisplay="Top">            
            <Columns>
                <telerik:GridEditCommandColumn UniqueName="GridEditAccountInfo">
                </telerik:GridEditCommandColumn>
                <telerik:GridBoundColumn DataField="FirstName" AllowSorting="true" Visible="true"
                    HeaderText="First Name">
                </telerik:GridBoundColumn>
                <telerik:GridBoundColumn DataField="LastName" AllowSorting="true" Visible="true"
                    HeaderText="Last Name">
                </telerik:GridBoundColumn>
                <telerik:GridBoundColumn DataField="UserName" AllowSorting="true" Visible="true"
                    HeaderText="User Name">
                </telerik:GridBoundColumn>
            </Columns>
            <EditFormSettings  EditFormType="Template">
                <FormTemplate>
                    <telerik:RadTabStrip ID="userTabStrip" runat="server" SelectedIndex="0" MultiPageID="UserMultiPage1" >
                        <Tabs>
                            <telerik:RadTab runat="server" Text="Account Info" PageViewID="AccountInfoPageView">
                            </telerik:RadTab>
                            <telerik:RadTab runat="server" Text="Address Info" PageViewID="AddressInfoPageView">
                            </telerik:RadTab>
                            <telerik:RadTab runat="server" Text="Roles" PageViewID="RolesPageView">
                            </telerik:RadTab>
                        </Tabs>
                    </telerik:RadTabStrip>
                    <telerik:RadMultiPage runat="server" ID="UserMultiPage1" SelectedIndex="0" RenderSelectedPageOnly="false">
                        <telerik:RadPageView runat="server" ID="AccountInfoPageView">
                            <asp:Label ID="lblUserName" Font-Bold="true" Font-Italic="true" Text='<%# Eval("Username") %>'
                                Visible="false" runat="server" />
                            <dd:AccountInfo runat="server" ID="EditAccountInfo" />
                        </telerik:RadPageView>
                        <telerik:RadPageView runat="server" ID="AddressInfoPageView">
                            <dd:AddressInfo runat="server" ID="EditAddressInfo" />
                        </telerik:RadPageView>
                        <telerik:RadPageView runat="server" ID="RolesPageView">
                            <dd:RoleInfo runat="server" ID="EditRoleInfo" />
                        </telerik:RadPageView>
                    </telerik:RadMultiPage>
                    <br />
                    <asp:Button ID="btnUpdate" runat="server" Text='<%# IIf((TypeOf(Container) is GridEditFormInsertItem), "Insert", "Update") %>'
                            CommandName='<%# IIf((TypeOf(Container) is GridEditFormInsertItem), "Insert", "Update")%>' TabIndex="40"  CausesValidation="False" /> 
                    <asp:Button ID="btnCancel" runat="server" Text="Cancel" TabIndex="41" />
                </FormTemplate>
            </EditFormSettings>            
        </MasterTableView>
  
<HeaderStyle CssClass="RadGridHeader"></HeaderStyle>
  
        <ClientSettings EnableRowHoverStyle="true">
            <Selecting AllowRowSelect="True" />
        </ClientSettings>
        <SelectedItemStyle BorderColor="Yellow" BorderWidth="2px" BackColor="Yellow" Font-Bold="true" />
<AlternatingItemStyle Font-Size="11px"></AlternatingItemStyle>
  
<ItemStyle Font-Size="11px"></ItemStyle>
  
        <PagerStyle Mode="NextPrevAndNumeric"></PagerStyle>
</telerik:RadGrid>

Any and all help appreciated!

Jon

4 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 14 Oct 2010, 02:26 PM
Hello,

Checkout the section 'Setting properties without using binding expressions' in the following documentation to know about how to access the control in usercontrol where the UC is placed in EditForm.
Custom edit forms

Also go through the follwoing link:
Referencing controls in grid row/edit form


Thanks,
Princy.
0
Jon
Top achievements
Rank 1
answered on 14 Oct 2010, 08:13 PM

Thanks Princy,

The information I was missing was using the Parent.BindingContainer.DataItem (in the article from the first link you sent). With this, I was able to make the selections I needed by hooking the DataBound event for the dropdownlist and then assigning the SelectedValue.

 

Thanks again!

 

Jon

0
Larry
Top achievements
Rank 1
answered on 12 May 2011, 08:08 PM
The links you provided here are broken.
0
Tsvetina
Telerik team
answered on 18 May 2011, 08:44 AM
Hello Larry,

Try these links, they lead to the same help articles:

Custom edit forms
Referencing controls in grid row/edit form

Greetings,
Tsvetina
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.

Tags
Grid
Asked by
Jon
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Jon
Top achievements
Rank 1
Larry
Top achievements
Rank 1
Tsvetina
Telerik team
Share this question
or