Hi Telerik team,
I'm using RadGridView and I'm facing a strange problem now. I've:
Everything work fine except paging next page, it can't next to page 3 because SelectMethod of ObjectDataSource always run twice with startRowIndex = 0 at the first time run:
After debug I found this problem cause of loading usercontrol to panel if panel markup like this:
or
problem not occur.
So what is exactly problem here? It's my fault or it is by design?
Thanks so much.
I'm using RadGridView and I'm facing a strange problem now. I've:
- 1 default.aspx that have an asp:panel
- 1 usercontrol uc1 that have a RadGridView with Custom Paging using ObjectDataSource
In default.aspx page_load event I load uc1 into the panel:
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load Dim uc As UserControl = Page.LoadControl("~/uc1.ascx") pnlGrid.Controls.Add(uc)End SubEverything work fine except paging next page, it can't next to page 3 because SelectMethod of ObjectDataSource always run twice with startRowIndex = 0 at the first time run:
<asp:ObjectDataSource runat="server" ID="odsTest" TypeName="WebApplication2.BL" EnablePaging="true" SelectMethod="GetAllTest" SelectCountMethod="GetTestCount" MaximumRowsParameterName="maximumRows" StartRowIndexParameterName="startRowIndex"></asp:ObjectDataSource>After debug I found this problem cause of loading usercontrol to panel if panel markup like this:
<asp:Panel ID="pnlGrid" runat="server"></asp:Panel>(There are a <asp:Literal> control auto-generated here)
But if panel markup like:
<asp:Panel ID="pnlGrid" runat="server"></asp:Panel><asp:Panel ID="pnlGrid" runat="server"/>So what is exactly problem here? It's my fault or it is by design?
Thanks so much.
8 Answers, 1 is accepted
0
tungnt185
Top achievements
Rank 2
answered on 23 May 2013, 02:46 AM
Anyone at Telerik can help me to clarify this problem?
Thanks
Thanks
0
Hi,
Basically there should be no problem when defining the Panel control by different means yet this is the same control.
Could you share your RadGrid mark-up with the code-behind file. Thus I will be able to examine your code and let you know what could possibly lead to this behavior.
Regards,
Andrey
Telerik
Basically there should be no problem when defining the Panel control by different means yet this is the same control.
Could you share your RadGrid mark-up with the code-behind file. Thus I will be able to examine your code and let you know what could possibly lead to this behavior.
Regards,
Andrey
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 their blog feed now.
0
tungnt185
Top achievements
Rank 2
answered on 24 May 2013, 12:23 PM
Thanks Andrey for your response.
Below is my markup and code. Please examine it.
Default.aspx:
Default.aspx.vb
TestUC.ascx
BL.vb
Below is my markup and code. Please examine it.
Default.aspx:
<%@ Page Language="vb" AutoEventWireup="false" CodeBehind="Default.aspx.vb" Inherits="WebApplication2._Default" %><%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %><!DOCTYPE html><html xmlns="http://www.w3.org/1999/xhtml"><head runat="server"> <title></title></head><body> <form id="form1" runat="server"> <telerik:RadScriptManager runat="server" ID="RadScriptManager" AsyncPostBackTimeout="600"> </telerik:RadScriptManager> <telerik:RadStyleSheetManager ID="RadStyleSheetManager1" runat="server" /> <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server"> </telerik:RadAjaxManager> <telerik:RadAjaxLoadingPanel ID="RadAjaxLoadingPanel1" runat="server"> </telerik:RadAjaxLoadingPanel> <asp:Panel runat="server" ID="pnlTest"> </asp:Panel> </form></body></html>Default.aspx.vb
Imports System.Data.CommonImports Telerik.Web.UIPublic Class _Default Inherits System.Web.UI.Page Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load If String.IsNullOrEmpty(CurrentControl) Then LoadUserControl("~/TestUC.ascx") Else LoadUserControl(CurrentControl) End If End Sub Private sCurrentControlKey As String = "CurrentControl" Public Property CurrentControl() As String Get Return IIf(Me.ViewState(sCurrentControlKey) Is Nothing, String.Empty, CType(Me.ViewState(sCurrentControlKey), String)) End Get Set(ByVal value As String) Me.ViewState(sCurrentControlKey) = value End Set End Property Private Sub LoadUserControl(controlName As String) pnlTest.Controls.Clear() Dim MyControl As UserControl = CType(Page.LoadControl(controlName), UserControl) Dim userControlID As String = controlName.Split(".")(0) MyControl.ID = userControlID.Replace("/", "").Replace("~", "") pnlTest.Controls.Add(MyControl) Me.CurrentControl = controlName End SubEnd ClassTestUC.ascx
<%@ Control Language="vb" AutoEventWireup="false" CodeBehind="TestUC.ascx.vb" Inherits="WebApplication2.TestUC" %><%@ Register TagPrefix="telerik" Namespace="Telerik.Web.UI" Assembly="Telerik.Web.UI" %><telerik:RadAjaxManagerProxy ID="RadAjaxManagerProxy1" runat="server"> <AjaxSettings> <telerik:AjaxSetting AjaxControlID="grdTest"> <UpdatedControls> <telerik:AjaxUpdatedControl ControlID="grdTest" LoadingPanelID="RadAjaxLoadingPanel1" /> </UpdatedControls> </telerik:AjaxSetting> </AjaxSettings></telerik:RadAjaxManagerProxy><asp:ObjectDataSource runat="server" ID="odsTest" TypeName="WebApplication2.BL" EnablePaging="true" SelectMethod="GetAllData" SelectCountMethod="GetDataCount" MaximumRowsParameterName="maximumRows" StartRowIndexParameterName="startRowIndex"></asp:ObjectDataSource><telerik:RadGrid ID="grdTest" runat="server" DataSourceID="odsTest" AllowPaging="true" PagerStyle-Position="Bottom" AllowMultiRowSelection="true" AllowSorting="true" CellSpacing="0" GridLines="None"> <MasterTableView Width="100%" CommandItemDisplay="Top" AutoGenerateColumns="false" AllowMultiColumnSorting="true" DataKeyNames="ID"> <Columns> <telerik:GridClientSelectColumn></telerik:GridClientSelectColumn> <telerik:GridTemplateColumn UniqueName="Title" SortExpression="Title" DataField="Title"> <ItemTemplate> <table> <tr> <td><%# Eval("Title")%></td> </tr> </table> </ItemTemplate> </telerik:GridTemplateColumn> </Columns> </MasterTableView> <CommandItemStyle Height="27px"></CommandItemStyle> <ClientSettings> <Selecting AllowRowSelect="true" /> </ClientSettings></telerik:RadGrid>BL.vb
Imports System.Data.CommonImports Microsoft.Practices.EnterpriseLibrary.DataPublic Class BL Private db As Database Public Function GetData(ByVal startRowIndex As Integer, ByVal maximumRows As Integer) As DataTable Dim cmd As DbCommand = db.GetStoredProcCommand("ProcGetData", startRowIndex, maximumRows) cmd.CommandType = CommandType.StoredProcedure cmd.CommandTimeout = 30 Return db.ExecuteDataSet(cmd).Tables(0) End Function Public Function GetDataCount() As Integer Dim cmd As DbCommand = db.GetStoredProcCommand("ProcGetDataCount") cmd.CommandType = CommandType.StoredProcedure cmd.CommandTimeout = 30 Return CInt(db.ExecuteScalar(cmd)) End Function Public Sub New() db = DatabaseFactory.CreateDatabase("testConn") End SubEnd Class0
Hi,
Based on your code I see that you are not using the RadGrid custom paging but you are using the ObjectDataSource built-in paging. In this case what you could do is to place a break-point in the GetData method and inspect the parameter that are passed and their values. Most probably the problem comes from wrong values passed to the GetData method.
Regards,
Andrey
Telerik
Based on your code I see that you are not using the RadGrid custom paging but you are using the ObjectDataSource built-in paging. In this case what you could do is to place a break-point in the GetData method and inspect the parameter that are passed and their values. Most probably the problem comes from wrong values passed to the GetData method.
Regards,
Andrey
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 their blog feed now.
0
tungnt185
Top achievements
Rank 2
answered on 19 Jun 2013, 08:27 AM
Hi Andrey,
I know the problem is wrong values of parameter in GetData method but why this method is always run twice?
You can try my code to examine the problem.
Thanks
I know the problem is wrong values of parameter in GetData method but why this method is always run twice?
You can try my code to examine the problem.
Thanks
0
Hi,
How did you check that the method run twice? Using a break-point in code or using SQL profiler?
Regards,
Andrey
Telerik
How did you check that the method run twice? Using a break-point in code or using SQL profiler?
Regards,
Andrey
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.
0
tungnt185
Top achievements
Rank 2
answered on 20 Jun 2013, 01:50 AM
Hi Andrey,
I used break-point.
This method always run twice with startRowIndex = 0 at the first time run but I don't know why?
Regards
I used break-point.
This method always run twice with startRowIndex = 0 at the first time run but I don't know why?
Regards
0
Hello,
This is a common scenario for ObjectDataSource control as you could verify from this and many other threads around the internet.
You could make the ObjectDataSource control make only one call by turning on the caching of the control by using EnableCaching property.
Regards,
Andrey
Telerik
This is a common scenario for ObjectDataSource control as you could verify from this and many other threads around the internet.
You could make the ObjectDataSource control make only one call by turning on the caching of the control by using EnableCaching property.
Regards,
Andrey
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.