Rebinding RadComboBox contained in RadListView on RadWindow Closing

4 posts, 0 answers
  1. Amy
    Amy avatar
    113 posts
    Member since:
    Aug 2010

    Posted 03 Aug 2011 Link to this post

    Hi!  I need to have a RadComboBox, contained within a RadListView, rebind upon a RadWindowClosing. 

    I followed the solution from http://www.telerik.com/community/forums/aspnet/window/rebind-radcombobox-when-radwindow-closed.aspx.  However cannot seem to access the RadComboBox in the code behind.

    Here's the relevant code from the aspx page:
    // Javascript
    function closeRadWindow() {
        $find("<%= RadAjaxManager1.ClientID %>").ajaxRequest();
    }

    function openWin() {
         var oWnd = radopen("/TestDevelopment/Controls/CopyrightHolder.aspx", "winCopyright");
    }   

     // RadAjaxManager and RadWindow declaractions
        <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server" UpdatePanelsRenderMode="Inline"
            DefaultLoadingPanelID="RadAjaxLoadingPanel1" onajaxrequest="RadAjaxManager1_AjaxRequest">
            <AjaxSettings>
                <telerik:AjaxSetting AjaxControlID="RadListView1"
                 <UpdatedControls
                    <telerik:AjaxUpdatedControl ControlID="cboHolder" /> 
                 </UpdatedControls
              </telerik:AjaxSetting>
            </AjaxSettings>
        </telerik:RadAjaxManager>
         <telerik:RadWindowManager>
            <Windows>
                <telerik:RadWindow ID="winCopyright" Modal="true" Behaviors="Close, Move"
                    NavigateUrl="/TestDevelopment/Controls/CopyrightHolder.aspx" runat="server"
                    Width="870px" Height="515px" OnClientClose="closeRadWindow">
                </telerik:RadWindow>           
            </Windows>
        </telerik:RadWindowManager>
     
    // Button
    <input type="button" id="btnHolder" runat="server" value="Holder" onclick="openWin(); return false;" />

    Here's the relevant code from the vb page:
    Protected Sub RadAjaxManager1_AjaxRequest(ByVal sender As Object, ByVal e As AjaxRequestEventArgs)
            Dim cb As RadComboBox = DirectCast(RadListView1.FindControl("cboHolder"), RadComboBox)
            cb.DataBind()
    End Sub

    I get an error saying 'object reference not set to an instance of an object', and when debugging through the code I see that it's not able to find the RadComboBox.  I'm guessing perhaps this has something to do with the button only being in the Edit and Insert Item Templates?

    Any assistance would be greatly appreciated, thank you!
  2. Marin Bratanov
    Admin
    Marin Bratanov avatar
    4616 posts

    Posted 08 Aug 2011 Link to this post

    Hello Amy,

    I am not sure exactly what you are trying to achieve, yet accessing controls like this in a databound container (such as the RadListView, a Grid, etc) needs to go through some event of the said control that exposes the row which contains one instance of the control you wish to access. Such a direct approach could work if you rebind the entire listview, so this is one way to do this.

    Please try incorporating this functionality in your project and if you are still having difficulties I would advise that you open a support ticket and send us a working sample that we can examine, as currenlty we can only be guessing what your exact setup and needs are and without being able to experience your issue there is very little advise that can be given.


    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.

  3. Amy
    Amy avatar
    113 posts
    Member since:
    Aug 2010

    Posted 10 Aug 2011 Link to this post

    Thank you for your reply.  I need to rebind a RadComboBox, which is within a RadListView, when a RadWindow is closed.

    In the Edit and Insert Templates there is a RadComboBox which displays a list of company names.  The end-user can choose from an existing entry in the RadComboBox or if an entry they need doesn't exist they can click a RadButton which opens a RadWindow where they can add a new company.

    Currently if a user adds an entry while in the pop-up window when they close that window and go back to the RadCombobox in the Edit or Insert Item Template the added entry does not show.  The page has to be refreshed or the user must go out of the page and back in.

    I need the RadComboBox to rebind/refresh and show the recently added entry.

    I did try rebinding the RadListView itself, but that actually ended up causing an additional RadListView to show on the page.

    There is no RadListView event that would be applicable to use.  A user clicks the button adds an entry in the pop-up window, closes the window, and then returns to the main page with the RadListView.  

    The example in the link I mentioned in my orginal post does not show any RadListView event being used.  The solution provided states "You can invoke an ajaxRequest() in the OnClientclose event handler. Then in the Event handler rebind the radcombobox."

    This isn't working for me because when I try to do the rebinding of the RadComboxBox it's not able to find a reference to it.  I guessing this is because the RadComboBox is contained within the RadListView, and I need to reference the combobox by 1st getting reference to the listview.

    In our web application we have RadListViews on other pages where we get access to a RadComboBox within the list view with the following line of code:
    Dim cb As RadComboBox = DirectCast(RadListView1.FindControl("cboHolder"), RadComboBox)

    Unfortunately that doesn't seem to work in this case.
  4. Radoslav
    Admin
    Radoslav avatar
    1566 posts

    Posted 15 Aug 2011 Link to this post

    Hi Amy,

    I am sending you a simple example which demonstrates how to achieve the desired functionality. Please check it out and let me know if it helps you.

    Looking forward for your reply.

    Greetings,
    Radoslav
    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