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

[Solved] Pagesize combobox in Rad Grid is erroing out when paging is enabled

5 Answers 149 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Indira
Top achievements
Rank 1
Indira asked on 05 Apr 2011, 05:22 PM

We ran in to an issue with page size combobox events being null in Rad Ajax when paging is enabled with mode.
Error at:

 

 

$removeHandler=Sys.UI.DomEvent.removeHandler=

function(a,e,f){var d=null,c=a._events[e];for(var b=0,g=c.length;b<g;b++)if(c[b].handler===f){d=c[b].browserHandler;break}if(a.removeEventListener)a.removeEventListener(e,d,false);else if(a.detachEvent)a.detachEvent("on"+e,d);c.splice(b,1)};
Microsoft JScript runtime error: '_events' is null or not an object.

Here is the code we are using..
Menu.XML:

<?xml version="1.0" encoding="utf-8" ?>
<Menu>
  <Group Flow="Horizontal">
    <Item  Text="Home" NavigateUrl="~/Default.aspx">
    </Item>
    <Item IsSeparator="True" />
    <Item  Text="Help" ></Item>
  </Group>
</Menu>

MasterPage.aspx


<%@ Master Language="C#" AutoEventWireup="true" CodeFile="MasterPage.master.cs" Inherits="MasterPage" %>
<%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<head runat="server">
    <title></title>
    <asp:ContentPlaceHolder ID="head" runat="server">
    </asp:ContentPlaceHolder>
</head>
<body>
    <form id="form1" method="post" runat="server" style="height: 100%;" enctype="multipart/form-data">
    <telerik:RadScriptManager ID="RadScriptManager1" runat="server" EnablePageMethods="True"
        OutputCompression="Forced">
    </telerik:RadScriptManager>
    <telerik:RadStyleSheetManager ID="RadStyleSheetManager1" runat="server" />
    <telerik:RadSkinManager ID="RadSkinManager1" Skin="Office2007" runat="server" />
    <div style="width: 99%; height: 15%; float: left; padding-left: 1%;" class="body">
        <table width="100%">
            <tr>
                <td align="left">
                    <asp:ContentPlaceHolder ID="ContentPageMenu" runat="server">
                        <div style="width: 100%; padding-bottom: 4px; padding-top: 3px; float: left;">
                            <asp:UpdatePanel ID="UpdPanelPageContainerHeader" runat="server" UpdateMode="Always">
                                <ContentTemplate>
                                    <telerik:RadMenu runat="server" ID="RadMainMenu" DataFieldID="ID" Skin="Office2007"
                                        CssClass="menu" DataFieldParentID="ParentID" EnableRoundedCorners="true" EnableShadows="true">
                                        <DataBindings>
                                            <telerik:RadMenuItemBinding Depth="0" TextField="Text" Value="Key" />
                                            <telerik:RadMenuItemBinding Depth="1" ImageUrlField="ImageUrl" TextField="Text" />
                                        </DataBindings>
                                    </telerik:RadMenu>
                                </ContentTemplate>
                            </asp:UpdatePanel>
                        </div>
                    </asp:ContentPlaceHolder>
                </td>
                <td align="right" style="vertical-align: top;">
                              Welcome <asp:Label ID="LblUName"
                        runat="server" ForeColor="Blue" Text="Indira"></asp:Label>   <asp:Label
                            ID="LblSystem" runat="server" Text="" ForeColor="Blue"></asp:Label>   
                    <span style="color: Blue; font-size: 9pt; color: Black;" id="dt"></span>
                </td>
            </tr>
        </table>
    </div>
    <div style="width: 95%; height: 85%; float: left; padding-left: 5%;" class="body">
        <table style="border: solid 1px white; height: 100%" cellpadding="0" cellspacing="0"
            width="100%">
            <tr>
                <td>
                    <asp:ContentPlaceHolder ID="ContentPage" runat="server">
                    </asp:ContentPlaceHolder>
                </td>
            </tr>
        </table>
    </div>
    </form>
</body>
</html>

MasterPage.aspx.cs

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
  
public partial class MasterPage : System.Web.UI.MasterPage
{
    protected void Page_Load(object sender, EventArgs e)
    {
        Response.Cache.SetNoStore();
        Response.Cache.SetCacheability(HttpCacheability.NoCache);
        Response.Cache.SetExpires(DateTime.Now.AddDays(-1)); 
        if (!IsPostBack)
        {
            this.RadMainMenu.LoadContentFile("~/resources/Menu.xml");
        }        
  
    }
}

DemoUserControl.ascx

<%@ Control Language="C#" AutoEventWireup="true" CodeFile="DemoUserControl.ascx.cs" Inherits="controls_DemoUserControl" %>
<%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %>
<telerik:RadAjaxManager ID="RadAjaxManagerSCRList" runat="server">
    <AjaxSettings>
        <telerik:AjaxSetting AjaxControlID="RadGridSCRList">
            <UpdatedControls>
                <telerik:AjaxUpdatedControl ControlID="RadGridSCRList" />
            </UpdatedControls>
        </telerik:AjaxSetting>
    </AjaxSettings>
</telerik:RadAjaxManager>
<telerik:RadAjaxPanel ID="PanelSCRList" runat="server">
</telerik:RadAjaxPanel>
<asp:Label ID="LblErrorMessage" runat="server" ForeColor="Red" Visible="false"></asp:Label><br />
<asp:Label ID="LblHeader" runat="server" Text="Change Requests:" Font-Bold="true"></asp:Label>
<telerik:RadGrid ID="RadGridSCRList" runat="server" Skin="Office2007" AutoGenerateColumns="false"
    PageSize="5" Width="75%" AllowPaging="true"  AllowSorting="true"
    PagerStyle-Mode="NextPrevAndNumeric" PagerStyle-Position="Top" PagerStyle-HorizontalAlign="Center"
    OnNeedDataSource="RadGridSCRList_NeedDataSource">
    <MasterTableView Name="SCRListMasterTable"
        runat="server" EnableViewState="true" AllowNaturalSort="false" ShowHeadersWhenNoRecords="true"
        CommandItemDisplay="Top" EditMode="InPlace" NoMasterRecordsText="" GroupLoadMode="Client">        
        <Columns>
            <telerik:GridEditCommandColumn UniqueName="EditCommandColumn" ButtonType="LinkButton"
                EditText="View" ItemStyle-Width="5%">
            </telerik:GridEditCommandColumn>
            <telerik:GridBoundColumn UniqueName="Name" HeaderText="SCR/PTR" HeaderButtonType="TextButton"
                DataField="SCR_NAME" ForceExtractValue="Always" ItemStyle-Width="13%" Groupable="true"
                 Resizable="true">
            </telerik:GridBoundColumn>
            <telerik:GridBoundColumn UniqueName="ChangeNumber" HeaderText="Change Number" HeaderButtonType="TextButton"
                DataField="ChangeNumberString" ForceExtractValue="Always" ItemStyle-Width="10%"
                Groupable="false">
            </telerik:GridBoundColumn>
            <telerik:GridBoundColumn UniqueName="DLTName" HeaderText="DLT" ForceExtractValue="Always"
                HeaderButtonType="TextButton" DataField="DLTName" ItemStyle-Width="16%" Groupable="true"
                DataType="System.String">
            </telerik:GridBoundColumn>
            <telerik:GridBoundColumn UniqueName="LibraryName" HeaderText="Release Library" DataField="LibraryName"
                ForceExtractValue="Always" ItemStyle-Width="21%" HeaderButtonType="TextButton"
                SortExpression="LIBRARY_INDEX asc" Groupable="true">
            </telerik:GridBoundColumn>
        </Columns>
        <GroupHeaderItemStyle BackColor="Transparent" />
    </MasterTableView>
    <SortingSettings EnableSkinSortStyles="false" />
    <ClientSettings EnableRowHoverStyle="true" AllowDragToGroup="true" 
        EnableAlternatingItems="true" EnablePostBackOnRowClick="false">
    </ClientSettings>
</telerik:RadGrid>

DemoUserControl.ascx.cs

using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Services;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Collections.Generic;
using System.ComponentModel.Design;
using Telerik.Web;
using Telerik.Web.UI;
  
public partial class controls_DemoUserControl : System.Web.UI.UserControl
{
    public int RowSize
    {
        set;
        get;
    }
      
    protected void RadGridSCRList_NeedDataSource(object source, GridNeedDataSourceEventArgs e)
    {
        DataTable dt = new DataTable();
        DataRow dr;
        dt.Columns.Add(new DataColumn("SCR_NAME"));
        dt.Columns.Add(new DataColumn("ChangeNumberString"));
        dt.Columns.Add(new DataColumn("DLTName", typeof(System.String)));
        dt.Columns.Add(new DataColumn("LibraryName"));
        dt.Columns.Add(new DataColumn("LIBRARY_INDEX"));
        int rowsLength = 5;
        if (RowSize > 0)
            rowsLength = RowSize;
        for (int i = 1; i < rowsLength + 1; i++)
        {
            dr = dt.NewRow();
            dr[0] = "SCR_NAME" + i.ToString();
            dr[1] = i;
            dr[2] = "DLT_NAME" + i.ToString();
            dr[3] = "LibraryName" + i.ToString();
            dr[4] = i;
            dt.Rows.Add(dr);
        }
        this.RadGridSCRList.DataSource = dt;
    }
    public void LoadData(int Rows)
    {
        if (Rows > 0)
            this.RowSize = Rows;
        this.RadGridSCRList.Rebind();
    }
}

Demo.aspx

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Demo.aspx.cs" Inherits="views_Demo" MasterPageFile="~/MasterPage.master" %>
<%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %>
<%@ Register Src="~/controls/DemoUserControl.ascx" TagName="SCRControl" TagPrefix="UC" %>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPage" Runat="Server">
        <fieldset style="float: left; display: inline-block;">
            <legend style="font-weight: bold; color: Black">Search Change Requests:</legend>
            <asp:UpdatePanel ID="UpdatePanelSCRSearch" runat="server" RenderMode="Inline" UpdateMode="Always">
                <ContentTemplate>
                    <table border="0" cellpadding="0" cellspacing="0" width="80%" style="padding-left: 18px;">
                        <tr style="height: 35px;">
                  <td  style="width: 5%; padding-top: 10px;">
                                Rows to Display<br />
                                <asp:DropDownList ID="DDLRows" runat="server" AutoPostBack="false">
                                    <asp:ListItem Text="5" Value="5" Selected ="True"></asp:ListItem>
                                    <asp:ListItem Text="10" Value="10"></asp:ListItem>
                                </asp:DropDownList>
                            </td>
                        </tr>
                    </table>
                    <table border="0" cellpadding="0" cellspacing="0" width="84%" style="padding-left: 18px;">
                        <tr style="height: 25px; padding-top: 10px;">
                            <td align="right" style="padding-right: 10px;">
                                <asp:Button ID="BtnSearch" runat="server" Text="Search" OnClick="BtnSearch_Click"
                                    CausesValidation="false" />
                            </td>
                        </tr>
                    </table>
                </ContentTemplate>
            </asp:UpdatePanel>
        </fieldset>
        <asp:UpdatePanel ID="UpdatePanelSCRSearchResults" runat="server" UpdateMode="Conditional"
            RenderMode="Inline" ChildrenAsTriggers="false">
            <Triggers>
                <asp:AsyncPostBackTrigger ControlID="BtnSearch" EventName="click" />
            </Triggers>
            <ContentTemplate>
                <asp:Label ID="LblErrorMessage" runat="server" ForeColor="Red" Visible="false"></asp:Label>
                <div id="SearchResultsDiv" runat="server" style="width: 100%; table-layout: fixed;"
                    visible="false">
                    <uc:scrcontrol id="SCRSearchList" runat="server"/>
                </div>
            </ContentTemplate>
        </asp:UpdatePanel>
    </asp:Content>

Demo.aspx.cs

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
  
public partial class views_Demo : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
  
    }
    protected void BtnSearch_Click(object sender, EventArgs e)
    {
        this.LblErrorMessage.Visible = false;
        this.SearchResultsDiv.Visible = true;
        this.SCRSearchList.LoadData(Convert.ToInt32(this.DDLRows.SelectedValue));
          
    }
}


 Appreciate quick response hopefully with a solution.

Thanks!

5 Answers, 1 is accepted

Sort by
0
Accepted
Pavel
Telerik team
answered on 07 Apr 2011, 09:30 AM
Hi Indira,

It seems the problem is caused by your ajax settings. You can try to remove the RadAjaxManager from the user control and and add the following settings in the content page:
<telerik:RadAjaxManager ID="RadAjaxManagerSCRList" runat="server">
    <AjaxSettings>
        <telerik:AjaxSetting AjaxControlID="SCRSearchList">
            <UpdatedControls>
                <telerik:AjaxUpdatedControl ControlID="SCRSearchList" />
            </UpdatedControls>
        </telerik:AjaxSetting>
    </AjaxSettings>
</telerik:RadAjaxManager>

Let me know if that works for you.

All the best,
Pavel
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Indira
Top achievements
Rank 1
answered on 07 Apr 2011, 04:38 PM
Hi Pavel,

Changing the Ajax settings per your suggestion has fixed the issue. I'm interested to know what might have went wrong with the settings I had previously and what are the best ways to use AjaxManager.

Thanks a bunch and I appreciate your help.

Indira
0
Pavel
Telerik team
answered on 08 Apr 2011, 06:35 AM
Hi Indira,

As a general guideline it is better to ajaxify the whole user control, instead of only a single control within it. Otherwise you should be careful not to create nested UpdatePanels as this is not supported and can produce unexpected results. I hope this helps.

Regards,
Pavel
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Aaditya
Top achievements
Rank 1
answered on 08 Aug 2013, 04:12 PM
Hi Pavel,
i am facing exact same problem.
i have my RadScript manager in the usercontrol,as u said where i need to replace that?(as my content page is usercontrol only)
i am confused where i need to replace..thanks in advance..
0
Maria Ilieva
Telerik team
answered on 13 Aug 2013, 10:22 AM
Hello Aaditya,

In case MasterPage is used you should place the RadScriptManager and RadAjaxManager on the MasterPage. In case you have a stand alone web form you should place them in the content page.

Regards,
Maria Ilieva
Telerik
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 the blog feed now.
Tags
Grid
Asked by
Indira
Top achievements
Rank 1
Answers by
Pavel
Telerik team
Indira
Top achievements
Rank 1
Aaditya
Top achievements
Rank 1
Maria Ilieva
Telerik team
Share this question
or