I have a RadGrid that populates its data via a Subprocedure, which calls a SQL Stored Procedure to bind the data.
I want to enable paging on this RadGrid but for some reason as soon as I attempt to move to the next page it seems to post back and do nothing.
If I return to my initial search page and essentially force it to rerun the Sub that calls the SQL Stored Proc (which forces a databind) then I can see it has the correct page selected, but this is not practical at all.
I was under the impression the Radgrid could query the data only once and then preserve the information in the RadGrid for use in offline paging?
I do not want to rebind the data each time they page through the Data-set since it never changes (it is statistical data nothing is input), and I do not understand from the examples I've read why I need to specify the paging information using the NeedDataSource since the data never changes, and I do not want it requerying the database (It already has grabbed all the records once on the initial page-load)
I am not defining a DataSource in the markup since I am doing that programmatically during the Subprocedure that references the SQL Stored Procedure (Which takes many parameters that need to be altered before used as parameters, hence why I have a Subprocedure to populate the initial Grid)
I have stripped out some of my excess code and tried to put some illustration above in case it helps. I would basically like this to function all client side so after the server intiially populates the RadGrid (which works fine), that further paging requests will simply page through that populated RadGrid and not require a post-back or rebind.
Hopefully there is something I am missing here that can be explained.
Thanks in advance
Private
Sub
PopulateMyData()
' initialize variables
Dim
sqlConn
As
New
SqlConnection(System.Configuration.ConfigurationManager.ConnectionStrings(
"SQLConn2010"
).ToString)
Dim
sqlCmd
As
New
SqlCommand(
""
, sqlConn)
' open sql connection
sqlConn.Open()
With
sqlCmd
.CommandType = CommandType.StoredProcedure
If
ThisVariable.Length > 0
Then
' passed array search
.CommandText =
"prRunThisProcedure"
.Parameters.AddWithValue(
"@VariableList"
, ThisVariable)
Else
' standard search
.CommandText =
"prRunThatProcedureInstead"
.Parameters.AddWithValue(
"@someVariable"
, NullString(SomeParameter))
.Parameters.AddWithValue(
"@anotherVariable"
, NullString(AnotherParameter))
End
If
End
With
' execute query and read into sql data adapter
Dim
daTestObject
As
New
SqlDataAdapter(sqlCmd)
' fill datatable with results from sql adapter
Dim
dtTestObject
As
New
DataTable()
dtTestObject.Columns.Add(
"Name"
, Type.
GetType
(
"System.String"
))
dtTestObject.Columns.Add(
"ReportInfoID"
, Type.
GetType
(
"System.String"
))
daTestObject.Fill(dtTestObject)
' retrieve rowcount
Dim
RowCount
As
Integer
= dtTestObject.Rows.Count
' set datasource and bind if records were returned from stored procedure
If
(RowCount > 0)
Then
' bind datasource
rgTestGrid.DataSource = dtTestObject
rgTestGrid.DataBind()
End
If
End
Sub
I want to enable paging on this RadGrid but for some reason as soon as I attempt to move to the next page it seems to post back and do nothing.
<
telerik:RadGrid
ID
=
"rgTestGrid"
runat
=
"server"
GridLines
=
"None"
Width
=
"700px"
AllowPaging
=
"true"
PageSize
=
"25"
EnableViewState
=
"true"
>
<
MasterTableView
Caption
=
"This is the data"
CommandItemDisplay
=
"Top"
CommandItemSettings-ShowAddNewRecordButton
=
"false"
DataKeyNames
=
"ReportInfoID"
AllowPaging
=
"true"
NoDetailRecordsText
=
"Nothing Found."
>
<
PagerStyle
Mode
=
"NumericPages"
/>
<
CommandItemSettings
ShowExportToExcelButton
=
"true"
ShowExportToPdfButton
=
"true"
/>
<
Columns
>
<
telerik:GridTemplateColumn
>
<
ItemTemplate
>
<
asp:Label
ID
=
"lblRowCount"
runat
=
"server"
Width
=
"30px"
/>
</
ItemTemplate
>
<
HeaderStyle
Width
=
"30px"
/>
</
telerik:GridTemplateColumn
>
<
telerik:GridButtonColumn
UniqueName
=
"ReportURL"
DataTextField
=
"Name"
CommandName
=
"Select"
></
telerik:GridButtonColumn
>
</
Columns
>
</
MasterTableView
>
</
telerik:RadGrid
>
If I return to my initial search page and essentially force it to rerun the Sub that calls the SQL Stored Proc (which forces a databind) then I can see it has the correct page selected, but this is not practical at all.
I was under the impression the Radgrid could query the data only once and then preserve the information in the RadGrid for use in offline paging?
I do not want to rebind the data each time they page through the Data-set since it never changes (it is statistical data nothing is input), and I do not understand from the examples I've read why I need to specify the paging information using the NeedDataSource since the data never changes, and I do not want it requerying the database (It already has grabbed all the records once on the initial page-load)
I am not defining a DataSource in the markup since I am doing that programmatically during the Subprocedure that references the SQL Stored Procedure (Which takes many parameters that need to be altered before used as parameters, hence why I have a Subprocedure to populate the initial Grid)
I have stripped out some of my excess code and tried to put some illustration above in case it helps. I would basically like this to function all client side so after the server intiially populates the RadGrid (which works fine), that further paging requests will simply page through that populated RadGrid and not require a post-back or rebind.
Hopefully there is something I am missing here that can be explained.
Thanks in advance