RadDataPager pagesize and ddlSort disabled until postback

5 posts, 0 answers
  1. Rob
    Rob avatar
    2 posts
    Member since:
    Aug 2012

    Posted 20 Nov 2012 Link to this post

    I have a RadlistView and RadDataPager working just fine, except that the pageSize dropdown at the top and the sort by: drop down at the bottom are disabled until the page postsback.  Here is my code:


    <%@ Page Title="Favorite Candidates"  Language="VB" MasterPageFile="~/App_Masters/Interior.master" AutoEventWireup="false" CodeFile="FavoriteCandidates.aspx.vb" Inherits="School_FavoriteCandidates" %>
     
    <%@ Register TagPrefix="telerik" Namespace="Telerik.Web.UI" Assembly="Telerik.Web.UI" %>
     
    <asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server">
    </asp:Content>
    <asp:Content ID="Content2" ContentPlaceHolderID="mainContent" Runat="Server">
     
        <telerik:RadWindowManager ID="RadWindowManager1" runat="server" VisibleOnPageLoad="True">
            <Windows>
                <telerik:RadWindow ID="RadWindow1" runat="server" Modal="True" NavigateUrl="CandidateNotes.aspx" VisibleOnPageLoad="False" Width="800px" AutoSize="true" AutoSizeBehaviors="HeightProportional" MinHeight="400px" MaxHeight="900px" Behaviors="Close, Move, Resize, Maximize"
                    
                    >
                </telerik:RadWindow>
            </Windows>
        </telerik:RadWindowManager>
     
        <script type="text/javascript">
            /* Show new window */
            function ShowNewWindow(CandidateID) {
                //Show new window
                //not providing a name as a second parameter
                // creates a new window
                var oWindow = window.radopen("CandidateNotes.aspx?edit_id=" + CandidateID, null);
                //Using the reference to the window its clientside methods can be called
                oWindow.setSize(800, 400);
            }
     
    </script>
     
        <telerik:RadFormDecorator ID="QsfFromDecorator" runat="server" DecoratedControls="All" EnableRoundedCorners="false" />
        <div>
            <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server">
                <AjaxSettings>
                    <telerik:AjaxSetting AjaxControlID="ListViewPanel1">
                        <UpdatedControls>
                            <telerik:AjaxUpdatedControl ControlID="ListViewPanel1" LoadingPanelID="RadAjaxLoadingPanel1">
                            </telerik:AjaxUpdatedControl>
                        </UpdatedControls>
                    </telerik:AjaxSetting>
                </AjaxSettings>
                <ClientEvents OnRequestStart="RequestStart"></ClientEvents>
            </telerik:RadAjaxManager>
     
     
     
            <table>
                <tr>
                    <td>
                        <h1>Favorite Candidates</h1>
                        <asp:Panel ID="ListViewPanel1" runat="server">
                            <telerik:RadListView ID="RadListView1" DataSourceID="SqlDataSource1" runat="server"
                                ItemPlaceholderID="CandidateContainer" DataKeyNames="CandidateID" AllowPaging="true"
                                OnItemCommand="RadListView1_ItemCommand" >
                                <LayoutTemplate>
                                    <!-- Set the id of the wrapping container to match the CLIENT ID of the RadListView control to display the ajax loading panel
                             In case the listview is embedded in another server control, you will need to append the id of that server control -->
                                    <fieldset id="FiledSet1" style="max-width946px;">
                                        <%--<legend>Candidates</legend>--%>
                                        <table cellpadding="0" cellspacing="0" width="100%">
                                            <tr>
                                                <td>
                                                    <telerik:RadDataPager ID="RadDataPager1" runat="server" PagedControlID="RadListView1"
                                                        PageSize="10" CssClass="pagerStyle" >
                                                        <Fields>
                                                            <telerik:RadDataPagerButtonField FieldType="FirstPrev"></telerik:RadDataPagerButtonField>
                                                            <telerik:RadDataPagerButtonField FieldType="Numeric" PageButtonCount="6"></telerik:RadDataPagerButtonField>
                                                            <telerik:RadDataPagerButtonField FieldType="NextLast"></telerik:RadDataPagerButtonField>
                                                            <telerik:RadDataPagerPageSizeField PageSizeComboWidth="60" PageSizeText="Page size: " />
                                                            <telerik:RadDataPagerGoToPageField CurrentPageText="Page: " TotalPageText="of" SubmitButtonText="Go"
                                                                TextBoxWidth="25"></telerik:RadDataPagerGoToPageField>
                                                            <telerik:RadDataPagerTemplatePageField>
                                                                <PagerTemplate>
                                                                    <div style="floatrightpadding-left50px;">
                                                                        <b>
                                                                            <asp:Label runat="server" ID="CurrentPageLabel" Text="<%# IIF((Container.Owner.TotalRowCount > 0), Container.Owner.StartRowIndex + 1, 0)%>"></asp:Label>
                                                                            to
                                                                            <asp:Label runat="server" ID="TotalPagesLabel" Text="<%# IIF((Container.Owner.TotalRowCount > 0), Container.Owner.StartRowIndex + Container.Owner.PageSize, 0) %>"></asp:Label>
                                                                            of
                                                                            <asp:Label runat="server" ID="TotalItemsLabel" Text="<%# Container.Owner.TotalRowCount%>"></asp:Label>
                                                                        </b>
                                                                    </div>
                                                                </PagerTemplate>
                                                            </telerik:RadDataPagerTemplatePageField>
                                                        </Fields>
                                                    </telerik:RadDataPager>
                                                </td>
                                            </tr>
                                        </table>
                                        <asp:PlaceHolder ID="CandidateContainer" runat="server"></asp:PlaceHolder>
                                        <div style="clearboth">
                                        </div>
                                        <table style="width100%margin-top5px;">
                                            <tr>
                                                <td style="">
                                                </td>
                                                <td style="text-alignrightwidth75%;">
    <asp:Label ID="lblSort1" runat="server" AssociatedControlID="ddListSort" Text="Sort by:"
    Style="padding-right5px;"></asp:Label>
                                                    <telerik:RadComboBox ID="ddListSort" runat="server" AutoPostBack="true" OnSelectedIndexChanged="ddListSort_SelectedIndexChanged">
                                                        <Items>
                                                            <telerik:RadComboBoxItem Text="-Select field to sort-" Value=""></telerik:RadComboBoxItem>
                                                            <telerik:RadComboBoxItem Text="Last Name" Value="NameLast"></telerik:RadComboBoxItem>
                                                            <telerik:RadComboBoxItem Text="First Name" Value="NameFirst"></telerik:RadComboBoxItem>
                                                            <telerik:RadComboBoxItem Text="Country" Value="Country"></telerik:RadComboBoxItem>
                                                            <telerik:RadComboBoxItem Text="Clear sort" Value="ClearSort"></telerik:RadComboBoxItem>
                                                        </Items>
                                                    </telerik:RadComboBox>
    <asp:RadioButtonList RepeatLayout="Flow" RepeatDirection="Horizontal" ID="rblSort"
    runat="server" AutoPostBack="true" OnSelectedIndexChanged="rblSort_SelectedIndexChanged">
                                                        <asp:ListItem Text="Ascending" Value="ASC" Selected="True"></asp:ListItem>
                                                        <asp:ListItem Text="Descending" Value="DESC"></asp:ListItem>
                                                    </asp:RadioButtonList>
                                                </td>
                                            </tr>
                                        </table>
                                    </fieldset>
                                </LayoutTemplate>
                                <ItemTemplate>
                                    <!--The widths/heights of the fieldset/outer tables in the item/edit/insert templates should match to avoid wrapping or visual discrepancies
                                 in the tiles layout-->
                                    <fieldset class="fieldset">
                                        <legend style="margin-bottom:0px;"> <a href="/School/Candidate.aspx?ID=<%# Eval("CandidateID")%>"><%# Eval("NameFirst")%> <%# Eval("NameLast")%></a> </legend>
                                        <table cellpadding="0" cellspacing="0" style="height100%;" width="100%">
                                            <tr>
                                                <td>
                                                    <table cellpadding="0" cellspacing="0">
                                                        <tr>
                                                            <td style="font-weight:bold;padding-right:5px;">
                                                                Positions Sought:
                                                            </td>
                                                            <td style="padding-right:5px;">
                                                                <%#Eval("CandidatePositions")%>
                                                            </td>
                                                        </tr>
                                                        <tr>
                                                            <td style="font-weight:bold;padding-right:5px;">
                                                                Total Experience:
                                                            </td>
                                                            <td style="padding-right:5px;vertical-align:bottom;">
                                                                <%#Eval("ExperienceTotal")%>
                                                            </td>
                                                        </tr>
                                                        <tr>
                                                            <td style="font-weight:bold;padding-right:5px;">
                                                                International Experience:
                                                            </td>
                                                            <td style="padding-right:5px;vertical-align:bottom;">
                                                                <%#Eval("ExperienceInternational")%>
                                                            </td>
                                                        </tr>
                                                        <tr>
                                                            <td style="font-weight:bold;padding-right:5px;">
                                                                Available:
                                                            </td>
                                                            <td style="padding-right:5px;">
                                                                <%#Eval("StartMonth")%>/<%#Eval("StartYear")%></td>
                                                        </tr>
                                                        <tr>
                                                            <td style="font-weight:bold;padding-right:5px;">
                                                                Marital Status:
                                                            </td>
                                                            <td style="padding-right:5px;vertical-align:bottom;">
                                                                <%#Eval("MaritalStatus")%>
                                                            </td>
                                                        </tr>
                                                        <%#If(Eval("MaritalStatusID") <> 6, ("<tr><td style=""font-weight:bold;padding-right:5px;"">Partner Name:</td><td style=""vertical-align:bottom;"">" & Eval("PartnerNameFirst") & " " & Eval("PartnerNameLast") & "</td></tr>"), "")%>
                                                    </table>
                                                </td>
                                                <td>
                                                    <table cellpadding="0" cellspacing="0">                                                  
                                                        <tr>
                                                            <td style="font-weight:bold;padding-right:5px;">
                                                                Associate:
                                                            </td>
                                                            <td style="padding-right:5px;">
                                                                <%#Eval("AssocFirst")%> <%#Eval("AssocLast")%>
                                                            </td>
                                                        </tr>
                                                        <tr>
                                                            <td style="font-weight:bold;padding-right:5px;">
                                                                Email:
                                                            </td>
                                                            <td style="padding-right:5px;">
                                                                <a href="mailto:<%#Eval("candEmail")%>"><%#Eval("candEmail")%></a>
                                                            </td>
                                                        </tr>
                                                        <tr>
                                                            <td style="font-weight:bold;padding-right:5px;">
                                                                Skype:
                                                            </td>
                                                            <td style="padding-right:5px;">
                                                                <a href="skype:<%#Eval("candSkype")%>?call"><%#Eval("candSkype")%></a>
                                                            </td>
                                                        </tr>
                                                        <tr>
                                                            <td style="font-weight:bold;padding-right:5px;">
                                                                Country:
                                                            </td>
                                                            <td style="padding-right:5px;">
                                                                <%#Eval("Country")%>
                                                            </td>
                                                        </tr>
                                                    </table>
                                                </td>
                                                <td style="vertical-align:top;">
                                                    <img src="/images/Candidates/c.<%# Eval("CandidateID")%>.jpg" alt="Candidate Photo"><br />
                                                </td>
                                            </tr>
                                            <tr>
                                                <td style="text-alignright" colspan="3">
                                                </td>
                                            </tr>
                                        </table>
                                                    <asp:panel ID="Panel1" runat="server">
                                                        <br /><a href="#" onclick="ShowNewWindow('<%# DataBinder.Eval(Container.DataItem, "CandidateID") %>'); return false;"><img src="/images/icons/notes.gif" style="width:22px;height:28px;vertical-align:middle" alt="Candidate Notes" />&nbsp;Notes</a>&nbsp;<asp:ImageButton runat="server" ID="cmdRemoveFromFavorites" ImageUrl="/images/icons/removeFavorite.gif" ToolTip="Remove From Favorites" Width="24px" Height="21px" ImageAlign="AbsMiddle" CommandName="remove" CommandArgument='<%# Eval("CandidateID")%>' />&nbsp;<asp:LinkButton ID="cmdLnkRemoveFromFavorites" runat="server" CommandName="remove" CommandArgument='<%# Eval("CandidateID")%>'>Remove Favorite</asp:LinkButton>
                                                    </asp:panel>
                                    </fieldset>
                                </ItemTemplate>
                                <EmptyDataTemplate>
                                    <fieldset style="width100%">
                                        <legend>Favorites</legend>No favorite candidates available.
                                    </fieldset>
                                </EmptyDataTemplate>
                            </telerik:RadListView>
                        </asp:Panel>
                    </td>
                </tr>
            </table>
            <br />
            <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:Main %>"
                SelectCommand="SELECT blah blah"
                DeleteCommand="DELETE blah blah"
                UpdateCommand="UPDATE blah blah" 
                ConflictDetection="CompareAllValues" 
                OldValuesParameterFormatString="original_{0}">
                <DeleteParameters>
                    <asp:Parameter Name="original_CandidateFavoriteID" Type="Int32"></asp:Parameter>
                    <asp:Parameter Name="original_CandidateID" Type="Int32" />
                    <asp:Parameter Name="original_SchoolID" Type="Int32" />
                </DeleteParameters>
                <UpdateParameters>
                    <asp:Parameter Name="CandidateID" Type="Int32"></asp:Parameter>
                    <asp:Parameter Name="SchoolID" Type="Int32"></asp:Parameter>
                    <asp:Parameter Name="original_CandidateFavoriteID" Type="Int32"></asp:Parameter>
                    <asp:Parameter Name="original_CandidateID" Type="Int32"></asp:Parameter>
                    <asp:Parameter Name="original_SchoolID" Type="Int32"></asp:Parameter>
                </UpdateParameters>
            </asp:SqlDataSource>
        </div>
    </asp:Content>
     
    
    
    
    Imports Telerik.Web.UI
    Imports System.Data.SqlClient
    Imports System.Configuration
     
    Partial Class School_FavoriteCandidates
        Inherits System.Web.UI.Page
     
     
        Protected Sub Page_Load(sender As Object, e As System.EventArgsHandles Me.Load
            SiteUser.RequireSchoolLogon()
            SqlDataSource1.SelectCommand = "blah blah blah"
        End Sub
     
        Protected Sub RadListView1_ItemCommand(ByVal sender As ObjectByVal e As RadListViewCommandEventArgs)
            If (e.CommandName = RadListView.UpdateCommandName) OrElse (e.CommandName = RadListView.CancelCommandName) Then
                RadListView1.InsertItemPosition = RadListViewInsertItemPosition.None
     
                RadListView1.FindControl("btnInitInsert").Visible = True
            ElseIf String.Equals(e.CommandName, "remove"Then
                For Each myFave As SchoolFavorite In SiteUser.School.SchoolFavorites
                    If myFave.CandidateID = e.CommandArgument Then
                        SiteUser.School.AddLogEntry("Removed " & myFave.Candidate.FullName & " from favorites""School")
                        myFave.Delete()
                        Exit For
                    End If
                Next
                SiteUser.School.SchoolFavoritesReset()
                Response.Redirect("/School/FavoriteCandidates.aspx")
            End If
        End Sub
     
        Protected Sub ddListSort_SelectedIndexChanged(ByVal sender As ObjectByVal e As RadComboBoxSelectedIndexChangedEventArgs)
            Dim rbl As RadioButtonList = TryCast(RadListView1.FindControl("rblSort"), RadioButtonList)
     
            'check the e.Value passed as an argument and fire sort command for the corresponding field. The exact item in the listview from which you trigger the 
            'command is not important
            'FireCommandEvent method invokes Rebind() implicitly, hence no explicit call is needed to refresh the listview
            Select Case e.Value
                Case "NameLast"
                    RadListView1.Items(0).FireCommandEvent(RadListView.SortCommandName, "NameLast")
                    rbl.SelectedIndex = 0
                    Exit Select
                Case "NameFirst"
                    RadListView1.Items(0).FireCommandEvent(RadListView.SortCommandName, "NameFirst")
                    rbl.SelectedIndex = 0
                    Exit Select
                Case "Country"
                    RadListView1.Items(0).FireCommandEvent(RadListView.SortCommandName, "Country")
                    rbl.SelectedIndex = 0
                    Exit Select
                Case "ClearSort"
                    RadListView1.SortExpressions.Clear()
                    RadListView1.Rebind()
                    rbl.SelectedIndex = 0
                    Exit Select
                Case Else
                    Exit Select
            End Select
        End Sub
        Protected Sub rblSort_SelectedIndexChanged(ByVal sender As ObjectByVal e As EventArgs)
            Dim rbl As RadioButtonList = TryCast(sender, RadioButtonList)
            Dim combo As RadComboBox = TryCast(RadListView1.FindControl("ddListSort"), RadComboBox)
     
            'check the selected value passed as an argument and fire sort command for the corresponding field. The exact item in the listview from which you trigger the 
            'command is not important
            'FireCommandEvent method invokes Rebind() implicitly, hence no explicit call is needed to refresh the listview
     
            If combo.SelectedItem.Value.ToString() <> [String].Empty AndAlso combo.SelectedItem.Value.ToString() <> "ClearSort" Then
                Select Case rbl.SelectedValue
                    Case "ASC"
                        RadListView1.Items(0).FireCommandEvent(RadListView.SortCommandName, combo.SelectedValue + " ASC")
                        Exit Select
                    Case "DESC"
                        RadListView1.Items(0).FireCommandEvent(RadListView.SortCommandName, combo.SelectedValue + " DESC")
                        Exit Select
                    Case Else
                        Exit Select
                End Select
            End If
        End Sub
     
     
    End Class
    
  2. Tsvetoslav
    Admin
    Tsvetoslav avatar
    1823 posts

    Posted 23 Nov 2012 Link to this post

    Hi Rober,

    I'd ask you to open up a formal support ticket and send a runnable sample where the issue is replicated as the code snippets provided do not supply enough information what the cause for the problem might be.

    Thanks for that.

    All the best, Tsvetoslav
    the Telerik team
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Roger Chen
    Roger Chen avatar
    2 posts
    Member since:
    Apr 2005

    Posted 15 May Link to this post

    Hi,

    I have exactly the same problem with a pure clean page(no code) that show a sql selection by a ListView and a DataPager, would you please share the result? Thanks!

     

    Best regards, Roger

  5. Rob
    Rob avatar
    2 posts
    Member since:
    Aug 2012

    Posted 17 May in reply to Roger Chen Link to this post

    This is what support sent and it worked great for me:

     

    "Posted on Nov 27, 2012
    Hi,

    Thank you for contacting us.

    Most probably the problem comes from a JavaScript error. This is caused by the fact that you have hooked the OnRequestStart event but you have not provided the actual event handler. Try to remove this line:


    <ClientEvents OnRequestStart="RequestStart"></ClientEvents>
    and you should have no problems using our controls.

    All the best,
    Andrey 
    the Telerik team"

  6. Roger Chen
    Roger Chen avatar
    2 posts
    Member since:
    Apr 2005

    Posted 17 May in reply to Rob Link to this post

    Cool, this solved my problem, many many thanks!

     

    Best regards,

    Roger Chen

Back to Top
UI for ASP.NET Ajax is Ready for VS 2017