asp.netnulltelerikraddatapager

RadDataPager findcontrol returns null in some situation


hi my dear friends :
i have a radcombobox that is in relationship with RadListViw (with RadDataPager Inside)...
when i change the item of rad combobox , so RadListView is Updated...
selectedIndexxhanged() server-side event...
my selectedIndexChanged() is like this :

protected void RadcbImagesGroup_SelectedIndexChanged(object sender, Telerik.Web.UI.RadComboBoxSelectedIndexChangedEventArgs e)
{
    rlvImages.DataBind();
    var raddatapager = (rlvImages).FindControl("RadDataPager1") as RadDataPager;
    if (raddatapager != null)
    {
        raddatapager.FireCommand("Page","First");
    }

}

my radComboBox Item values is like : 1,2,3...

in mode 1 we have 25 pages... in mode 2 we have 5 pages... in mode 3 we have 5 pages...

my problem is when we are in mode 1 and put the pageNumber to more than 5 and when i change the combobox Item to mode 2 so
var raddatapager = (rlvImages).FindControl("RadDataPager1") as RadDataPager; is null...

but if we put the page# (we are in mode 1) to lower than 5 or equal 5 , and change the radcb item to another everything works fine...

where is the null problem?

thanks in advance


Solution

  • i could n't figure out what was the null problem ...
    but the below code solved my issue by the other way :

     rlvImages.CurrentPageIndex = 0;
    

    instead of :

    var raddatapager = (rlvImages).FindControl("RadDataPager1") as RadDataPager;
    if (raddatapager != null)
    {
        raddatapager.FireCommand("Page","First");
    }