Hi,
I am using Custom paging with ObjectDataSource control and I am getting this error:
'ObjectDataSource 'ObjectDataSource1' could not find a non-generic method 'GetGLCount' that has parameters: startRowIndex, maximumRows. '
Can somebody help to identify where is the problem?
Thanks!
This my code:
[ASPX page]
<%
@ Page Language="vb" AutoEventWireup="false" CodeBehind="UsingObjectDataSource.aspx.vb" Inherits="TelerikTestingMillionRecords.UsingObjectDataSource" %>
<%
@ 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">
<
html xmlns="http://www.w3.org/1999/xhtml" >
<
head runat="server">
<title>Untitled Page</title>
</
head>
<
body>
<form id="form1" runat="server">
<div>
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
<telerik:RadAjaxManager ID="RadAjaxManager1" runat="server">
<AjaxSettings>
<telerik:AjaxSetting AjaxControlID="RadGrid1">
<UpdatedControls>
<telerik:AjaxUpdatedControl ControlID="RadGrid1" />
</UpdatedControls>
</telerik:AjaxSetting>
</AjaxSettings>
</telerik:RadAjaxManager>
<telerik:RadGrid ID="RadGrid1" runat="server" Width="95%" Skin="Hay"
DataSourceID="ObjectDataSource1"
ShowGroupPanel="True"
ShowStatusBar="True"
AllowPaging="True"
AllowSorting="True" GridLines="None">
<ClientSettings AllowDragToGroup="true" />
<HeaderContextMenu Skin="Hay">
<CollapseAnimation Type="OutQuint" Duration="200"></CollapseAnimation>
</HeaderContextMenu>
<PagerStyle Mode="NextPrevAndNumeric"></PagerStyle>
<MasterTableView OverrideDataSourceControlSorting="true" />
<FilterMenu Skin="Hay">
<CollapseAnimation Type="OutQuint" Duration="200"></CollapseAnimation>
</FilterMenu>
</telerik:RadGrid>
<asp:ObjectDataSource ID="ObjectDataSource1" runat="server"
EnablePaging="True"
SelectCountMethod="GetGLCount"
SelectMethod="GetGLSubSet"
OldValuesParameterFormatString="original_{0}"
TypeName="TelerikTestingMillionRecords.SQLDataManager">
<SelectParameters>
<asp:Parameter DefaultValue="1" Name="startRowIndex" Type="Int32" />
<asp:Parameter DefaultValue="15" Name="maximumRows" Type="Int32" />
</SelectParameters>
</asp:ObjectDataSource>
</div>
</form>
</
body>
</
html>
[Code Behind]
Imports
System.Data.SqlClient
Imports
Telerik.Web.UI
Imports
TelerikTestingMillionRecords.SQLDataManager
Partial
Public Class UsingObjectDataSource
Inherits System.Web.UI.Page
Private Sub ObjectDataSource1_Selecting(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.ObjectDataSourceSelectingEventArgs) Handles ObjectDataSource1.Selecting
e.InputParameters(
"startRowIndex") = 1
e.InputParameters(
"maximumRows") = 15
End Sub
[DAL]
Imports
System.Data.SqlClient
Public
Class SQLDataManager
Public Sub New()
End Sub
Shared Function GetGLSubSet(ByVal startRowIndex As Integer, ByVal maximumRows As Integer) As Data.DataSet
' Data adapter to retrieve data from SQL Server based on the page size of the grid.
' The Select statement uses the maximumRows and startRowIndex parameters provided
' by WebGrid to query for data between the start row index for the page up to the page size.
Dim ConnString As String = ConfigurationManager.ConnectionStrings("PCRSQL2005ConnectionString").ConnectionString
'Create a connection to the SQL Server.
Dim conn As SqlConnection = New SqlConnection(ConnString)
conn.Open()
Dim MyDataAdapter As SqlDataAdapter
'Create a DataAdapter, and then provide the name of the stored procedure.
MyDataAdapter =
New SqlDataAdapter("GetPCRGLIFP100Subset", conn)
'Set the command type as StoredProcedure.
MyDataAdapter.SelectCommand.CommandType = CommandType.StoredProcedure
'Create and add a parameter to Parameters collection for the stored procedure.
MyDataAdapter.SelectCommand.Parameters.Add(
New SqlParameter("@startRowIndex", SqlDbType.Int))
MyDataAdapter.SelectCommand.Parameters.Add(
New SqlParameter("@maximumRows", SqlDbType.Int))
'Assign the search value to the parameter.
MyDataAdapter.SelectCommand.Parameters(
"@startRowIndex").Value = startRowIndex
MyDataAdapter.SelectCommand.Parameters(
"@maximumRows").Value = maximumRows
Dim ds As New DataSet
MyDataAdapter.Fill(ds)
MyDataAdapter.Dispose()
conn.Close()
Return ds
End Function
Public Shared Function GetGLCount() As Integer
' Data adapter to retrieve data from SQL Server based on the page size of the grid.
' The Select statement uses the maximumRows and startRowIndex parameters provided
' by WebGrid to query for data between the start row index for the page up to the page size.
Dim ConnString As String = ConfigurationManager.ConnectionStrings("PCRSQL2005ConnectionString").ConnectionString
'Create a connection to the SQL Server.
Dim conn As SqlConnection = New SqlConnection(ConnString)
conn.Open()
Dim MyDataAdapter As SqlDataAdapter
'Create a DataAdapter, and then provide the name of the stored procedure.
MyDataAdapter =
New SqlDataAdapter("GetPCRGLIFP100RowCount", conn)
'Set the command type as StoredProcedure.
MyDataAdapter.SelectCommand.CommandType = CommandType.StoredProcedure
'Create and add a parameter to Parameters collection for the stored procedure.
MyDataAdapter.SelectCommand.Parameters.Add(
New SqlParameter("@MaximumRows", SqlDbType.Int))
'Create and add an output parameter to Parameters collection.
'Set the direction for the parameter. This parameter returns the Rows returned.
MyDataAdapter.SelectCommand.Parameters(
"@MaximumRows").Direction = ParameterDirection.Output
Dim ds As New DataSet
MyDataAdapter.Fill(ds)
'Get the number of rows returned, and then assign it to the Label control.
'lblRowCount.Text = DS.Tables(0).Rows.Count().ToString() & " Rows Found!"
GetGLCount = MyDataAdapter.SelectCommand.Parameters(0).Value
MyDataAdapter.Dispose()
conn.Close()
End Function
End
Class