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

Problem with RadAjaxPanel + RadGrid (inside ascx control)

3 Answers 168 Views
Ajax
This is a migrated thread and some comments may be shown as answers.
vlad
Top achievements
Rank 1
vlad asked on 09 Nov 2011, 05:50 PM
Hi

I have an issue when using radgrid inside radajaxpanel.
Radgrid is contained in .ascx control, and uses an arraylist as datasource for test purposes.

Initially, grid renders just fine, but when trying to use sorting for example, it dissapears and is not rendered any more.

Also, when I place grid outside of radajaxpanel, it works just fine.


Here is my aspx code (CTRL:UserList contains the grid)

<telerik:RadAjaxLoadingPanel ID="uxRadAjaxLoadingPanel" Skin="Transparent" InitialDelayTime="200" MinDisplayTime="250" runat="server" />
<telerik:RadAjaxPanel Height="100" ID="uxRadAjaxPanel_Content" EnableAJAX="true" LoadingPanelID="uxRadAjaxLoadingPanel" runat="server"><CTRL:UserList ID="UserList1" runat="server" /></telerik:RadAjaxPanel>


Aspx for the grid

<telerik:RadGrid ID="uxRadGrid" Skin="Transparent" AutoGenerateColumns="false" ShowHeader="true" Width="100%"
OnNeedDataSource="uxRadGrid_NeedDataSource"
PagerStyle-AlwaysVisible="true" PagerStyle-Mode="NumericPages" PagerStyle-Position="Bottom" AllowPaging="true" AllowSorting="true"
runat="server">
    <MasterTableView ClientDataKeyNames="user_id" TableLayout="Auto" GridLines="None">
        <Columns>
            <telerik:GridBoundColumn DataField="user_id" HeaderText="Id" />
            <telerik:GridBoundColumn DataField="user_status" HeaderText="Etat" />
            <telerik:GridBoundColumn DataField="user_role" HeaderText="Rôle" />
            <telerik:GridBoundColumn DataField="user_firstname" HeaderText="Prénom" />
            <telerik:GridBoundColumn DataField="user_lastname" HeaderText="Nom" />
            <telerik:GridBoundColumn DataField="user_email" HeaderText="Courriel" />
        </Columns>
    </MasterTableView>
 
    <ClientSettings>
        <ClientEvents OnRowClick="uxRadGrid_RowClick" />
    </ClientSettings>
</telerik:RadGrid>


And code-behind

protected void uxRadGrid_NeedDataSource(object source, Telerik.Web.UI.GridNeedDataSourceEventArgs e)
{
    ArrayList list = new ArrayList();
 
    list.Add(new TestObject("tYYpcH", "Activé", "Administrateur", "Vedran", "Vlajki", "vedran.vlajki@hotesline.ch"));
    list.Add(new TestObject("zzz333", "Activé", "Administrateur", "Catherine", "Schneider", "catherine@mail.com"));
 
    uxRadGrid.DataSource = list;
}


What is wrong ? Thanks everybody !

3 Answers, 1 is accepted

Sort by
0
Iana Tsolova
Telerik team
answered on 14 Nov 2011, 10:29 AM
Hello Vlad,

I added the provided code to a runnable sample, however sorting works properly for the grid on my side. Can you try the attached web site and the test I made in this video and let me know if I mised something out?

Kind regards,
Iana Tsolova
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
0
vlad
Top achievements
Rank 1
answered on 16 Nov 2011, 04:43 PM
Thanks

I switched to RadAjaxManager

I also forgot to tell that the user control is loaded dynamically like this

protected void uxRadAjaxManager_AjaxRequest(object sender, AjaxRequestEventArgs e)
{
    try
    {
        //clear placeholder content
        uxPanel_Content.Controls.Clear();
 
        //parse command
        NameValueCollection qscoll = HttpUtility.ParseQueryString(e.Argument);
 
        //process command
        switch (qscoll["content"])
        {
            case "userlist":                 
                UI_CTRL_UserList userList = (UI_CTRL_UserList)LoadControl("UI_CTRL_UserList.ascx");
                userList.ID = "UI_CTRL_UserList";
                uxPanel_Content.Controls.Add(userList);
                break;
            case "userprofile": 
                UI_CTRL_UserProfile userProfile = (UI_CTRL_UserProfile)LoadControl("UI_CTRL_UserProfile.ascx");
                userProfile.ID = "UI_CTRL_UserProfile";
                userProfile.userId = qscoll["user_id"];
                uxPanel_Content.Controls.Add(userProfile);
                break;
        }
 
    }
    catch (Exception exception) { System.Diagnostics.Trace.TraceError("[ui_bo_profile.ascx.cs] uxRadAjaxManager_AjaxRequest failed : " + exception.Message); };
}


Am I missing something ?
0
Iana Tsolova
Telerik team
answered on 16 Nov 2011, 04:58 PM
Hi Vlad,

Are you recreating the dynamically loaded user controls on postback?
Try following the approach from this article and see if it helps.

Kind regards,
Iana Tsolova
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
Tags
Ajax
Asked by
vlad
Top achievements
Rank 1
Answers by
Iana Tsolova
Telerik team
vlad
Top achievements
Rank 1
Share this question
or