radwindow repeater selection back to parent

5 posts, 0 answers
  1. AName
    AName avatar
    14 posts
    Member since:
    Jul 2013

    Posted 30 Apr 2014 Link to this post

    Hi there,

    I have a radwindow that performs a search on data and displays a list within a repeater of options the user may select.
    What I need to do is collect the repeater object and send back to the parent. 

    I looked at some of your examples using javascript, the problem is using javascript to grab the data within the repeater is quite ugly.

    Is there a way I can pass the code back via code behind?
    So in my repeater I have a button "select" when user clicks the "select" button the radwindow closes and
    the parent receives the selection. 

    My repeater code

    ​<asp:Repeater ID="rptStores" runat="server" OnItemDataBound="rptStores_ItemDataBound">
    <tr style="color:#ffd700; font-weight:bold;">
    <td>Store Name</td>
    <tr style="color:#fff;" onmouseover="this.style.backgroundColor='blue'" onmouseout="this.style.backgroundColor=''" class="<%# If(Container.ItemIndex Mod 2 = 0, "TRNormal", "TRAlt") %>">
    <td style="padding: 4px;">
    <asp:Label ID="lblDBAName" runat="server" Text='<%# Eval("DBAName") %>' />
    <asp:HiddenField ID="hfRowID" runat="server" Value='<%# Eval("id") %>' />
    <td style="padding: 4px;">
    <asp:Label ID="lblCity" runat="server" Text='<%# Eval("State") +"-"+ Eval("City")%>' />
    <asp:HiddenField ID="hfState" runat="server" Value='<%# Eval("state") %>' />
    <td style="padding: 4px;">
    <asp:Label ID="lblStreet" runat="server" Text='<%# Eval("Street1") %>' />
    <asp:HiddenField ID="hfPhone" runat="server" Value='<%# Eval("phone") %>' />
    <td style="padding: 4px;">
    <asp:Label ID="lblDistance" runat="server" Text='<%# Eval("distance") %>' />
    <telerik:RadButton runat="server" Text="Select" ID="storeSelection2" CommandName="Process" Skin="Black" OnClientClicked="returnToParent"></telerik:RadButton>
    <asp:Label ID="lblEmptyData" Text="No Data To Display" runat="server" Visible="false"></asp:Label>

    my vb

    Protected Sub rptStores_ItemCommand(ByVal source As Object, ByVal e As System.Web.UI.WebControls.RepeaterCommandEventArgs) Handles rptStores.ItemCommand

    Dim dbaName As Label
    dbaName = CType(e.Item.FindControl("lblDBAName"), Label)

    Dim city As Label
    city = CType(e.Item.FindControl("lblCity"), Label)

    Dim state As HiddenField
    state = CType(e.Item.FindControl("hfState"), HiddenField)

    Dim phone As HiddenField
    phone = CType(e.Item.FindControl("hfPhone"), HiddenField)

    Dim street1 As Label
    street1 = CType(e.Item.FindControl("lblStreet"), Label)

    Dim selectedID As HiddenField
    selectedID = CType(e.Item.FindControl("hfRowID"), HiddenField)

    ProcessButton(dbaName.Text, street1.Text, city.Text, state.Value, phone.Value, selectedID.Value)

    End Sub

    ProcessButton is called AFTER a return to parent javascript call.

    Is this an option or do i really need to send object via javascript back to parent and then push into code behind.

  2. Marin Bratanov
    Marin Bratanov avatar
    4533 posts

    Posted 02 May 2014 Link to this post


    If the code in the RadWindow is in its own page, you can store data on the server, e.g., in the Session, so you can access it from the code-behind of the main page. You would still need some JavaScript to close the RadWindow and invoke a function on the main page that will POST it.

    Another option is to use the ContentTemplate of the RadWindow so the repeater is a part of the main page, which will let you access all control in it. The following demo shows the difference in accessing the controls and lists the pros and cons: http://demos.telerik.com/aspnet-ajax/window/examples/contenttemplatevsnavigateurl/defaultcs.aspx. You may also find useful this article on using AJAX in this scenario: http://www.telerik.com/help/aspnet-ajax/radwindow-ajaxifying.html.


    Marin Bratanov

    Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

  3. Julius
    Julius avatar
    8 posts
    Member since:
    Dec 2012

    Posted 07 Jul 2016 in reply to Marin Bratanov Link to this post

    Hi Marin,

    I tried putting in repeater inside RadWindow's ContentTemplate, but when saving the records, the values of the textbox inside repeater's itemtemplate is not according to what I put in, i.e. still the original data bound values. Is this a problem with the viewstate? Please find my code below. When I open the RadWindow, and change values in tbSequence, and hit a button click, the values are still the original databound values. Can you please advise?

    <telerik:RadWindowManager ID="RadWindowManager1" runat="server">
                <telerik:RadWindow ID="radBuildingPhotoEdit" runat="server" Title="Edit Building Photos" Width="700" Height="700" Modal="true" OnLoad="radBuildingPhotoEdit_Load"
                    Behaviors="Minimize, Move, Resize, Maximize, Close" ViewStateMode="Enabled">
                            <asp:FileUpload ID="fuBuildingPhoto" runat="server" />
                            <asp:Button ID="btnUploadBuildingPhoto" runat="server" Text="<%$ KFTranslate:Upload Photo%>" CausesValidation="false" OnClick="btnUploadBuildingPhoto_Click" />
                            <asp:Button ID="btnUpdateBuildingImageOrder" runat="server" Text="<%$ KFTranslate:Update Order%>" ValidationGroup="BuildingPhotos"
                                ToolTip="<%$ KFTranslate:Click on this button to update the order of building images%>" OnClick="btnUpdateBuildingImageOrder_Click" />            
                        <asp:Repeater ID="rptBuildingPhotosEdit" runat="server" OnItemDataBound="rptBuildingPhotosEdit_ItemDataBound" OnItemCommand="rptBuildingPhotosEdit_ItemCommand">
                                <div class="rptImages">                        
                                    <asp:TextBox ID="tbSequence" runat="server" CssClass="tbSequence" Text='<%#Eval("Sequence") %>' onkeypress="return isNumberKey(event)" />
                                    <asp:RequiredFieldValidator ID="reqSequence" runat="server" ControlToValidate="tbSequence" ValidationGroup="BuildingPhotos" ErrorMessage="*" 
                                        SetFocusOnError="true" ForeColor="Red"></asp:RequiredFieldValidator>
                                    <div style="margin-top: 5px">
                                        <asp:Image ID="imgBuildingPhoto" runat="server" />
                                        <asp:ImageButton ID="imgDeleteBuildingPhoto" runat="server" ImageUrl="~/Images/cross.png" Style="vertical-align: top"
                                            CommandName="Delete" CommandArgument='<%#Eval("ImageID") %>' OnClientClick="javascript:return confirm(document.getElementById('hidMsgConfirmDelete').value);" />
                                    <asp:Label ID="lblImageID" runat="server" Visible="false" Text='<%#Eval("BuildingLeaseSuiteImageID") %>'></asp:Label>



  4. Marin Bratanov
    Marin Bratanov avatar
    4533 posts

    Posted 07 Jul 2016 Link to this post

    Hi Julius,

    This shouldn't be happening and my best suggestion at the moment is to move this RadWindow out of the RadWindowManager, because when its ContentTemplate is used, a change in the server lifecycle may occur, as described here.


    Marin Bratanov
    Telerik by Progress
    Do you need help with upgrading your ASP.NET AJAX, WPF or WinForms projects? Check the Telerik API Analyzer and share your thoughts.
  5. Julius
    Julius avatar
    8 posts
    Member since:
    Dec 2012

    Posted 10 Jul 2016 in reply to Marin Bratanov Link to this post

    Thanks Marin. It works fine now :)
Back to Top