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

problems with PageIndexChanged

3 Answers 174 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Yanie
Top achievements
Rank 1
Yanie asked on 28 Feb 2012, 02:56 AM
hi there,

i have a problem with radgrid pageIndexChanged. i have a combobox where allow user to select state. when user select state, the radgrid will display all the data of selected state. but, when user want to go to next page, the data on grid was not based on the previous selected. i'll try to do PageIndexChanged event but error appear which is
'RadGrid1_PageIndexChanged' is not a member of 'ASP.default_aspx'."

my code is like below:

aspx

<telerik:RadGrid ID="RadGrid1" runat="server" CellSpacing="0" 
        DataSourceID="SqlDataSource1" GridLines="None" AllowFilteringByColumn="True" AllowSorting="True" PageSize="15"
            ShowFooter="True" AllowPaging="True" OnPageIndexChanged = "RadGrid1_PageIndexChanged" >

vb.net

Private Sub RadGrid1_PageIndexChanged(sender As Object, e As Telerik.Web.UI.GridPageChangedEventArgs) Handles RadGrid1.PageIndexChanged
        RadGrid1.CurrentPageIndex = e.NewPageIndex

'bind data based on selected state
        Dim str As String = "select username, name, levelAccess, description, status from [user] inner join par_branch on par_branch.id =         [user].branchNo where id = '" & RadComboBox2.SelectedItem.Value & "'"
        SqlDataSource1.SelectCommand = str
        SqlDataSource1.DataBind()
        RadGrid1.DataBind()
        RadGrid1.Visible = True

actually i always faced the same error for others telerik components. what it is about? anyone can help me?  


thanks in advanced.. 

3 Answers, 1 is accepted

Sort by
0
Tsvetina
Telerik team
answered on 01 Mar 2012, 04:15 PM
Hello Yanie,

Have you tried making the event handler a Protected member, instead of Private? When it is private it is accessble only from your page's code-behind and would work if you used the Handles clause.

All the best,
Tsvetina
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
Yanie
Top achievements
Rank 1
answered on 02 Mar 2012, 03:24 AM
Thanks Tsvetina. 

Unfortunately, the solution still not work for me. 

I've changed the previous code to:

 Protected Sub RadGrid1_PageIndexChanged(ByVal o As Object, e As Telerik.Web.UI.GridPageChangedEventArgs) Handles RadGrid1.PageIndexChanged
        RadGrid1.CurrentPageIndex = e.NewPageIndex


        Dim str As String = "select username, name, levelAccess, description, status from [user] inner join par_branch on par_branch.id = [user].branchNo where id = '" & RadComboBox2.SelectedItem.Value & "'"
        SqlDataSource1.SelectCommand = str
        SqlDataSource1.DataBind()
        RadGrid1.DataBind()
        RadGrid1.Visible = True
    End Sub

but, when i select another page, the data displayed is still not based on my selection on radcombobox. It displayed all data instead of displayed my selected branch only.  

Thanks in advanced. 
0
Tsvetina
Telerik team
answered on 06 Mar 2012, 10:58 AM
Hello Yanie,

If you have bound the grid to an SqlDataSource, you should better use the ItemCommand event to capture the Page command along with the command argument.
Then you should cancel the default command (e.Canceled=true), query the datasource and call Rebind() for the RadGrid.
 
Also, if you are aiming for custom paging, you could also take a look at the alternative approach shown here (the one using NeedDataSource):
http://demos.telerik.com/aspnet-ajax/grid/examples/programming/custompaging/defaultcs.aspx

All the best,
Tsvetina
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
Grid
Asked by
Yanie
Top achievements
Rank 1
Answers by
Tsvetina
Telerik team
Yanie
Top achievements
Rank 1
Share this question
or