Link to home
Start Free TrialLog in
Avatar of Howard Katz
Howard KatzFlag for United States of America

asked on

Telerik RadPanelBar inside FormView on Content page

Hello Experts,

How dow I get the Current Panel Item.  The demo on the Telerik website has this and it works

        private void GoToNextItem()
        {
            int selectedIndex = RadPanelBar1.SelectedItem.Index;

            if ((selectedIndex + 1) < RadPanelBar1.Items.Count)
            {
                RadPanelBar1.Items[selectedIndex + 1].Selected = true;
                RadPanelBar1.Items[selectedIndex + 1].Expanded = true;
                RadPanelBar1.Items[selectedIndex + 1].Enabled = true;
                RadPanelBar1.Items[selectedIndex].Expanded = false;
            }
        }

Since my RadPanelBar is inside a formview I need for use FindControl to see it.

           Telerik.Web.UI.RadPanelBar RadPanelBar1 = dvwOrders.FindControl("RadPanelBar1") as Telerik.Web.UI.RadPanelBar;
            Telerik.Web.UI.RadPanelItem thisRadPanelItem = RadPanelBar1.Items[0].Controls[0] as Telerik.Web.UI.RadPanelItem;

If then I try to do this, I get an error

int selectedIndex = RadPanelBar1.SelectedItem.Index;

Thank you

Howard



Avatar of Bob Learned
Bob Learned
Flag of United States of America image

It would be helpful to know the exception...
Avatar of Howard Katz

ASKER

I have changed this line from this:

   int selectedIndex = RadPanelBar1.SelectedItem.Index;

to this and I do not get the error.
 
   int selectedIndex = thisRadPanelItem.Index

The problem is that when I hit the Next button, the value of selectedIndex is always 0.
It seems that each time I hit the Next button, I re-initialize the control as if for the first time.  any ideas ?

Thanks



How are you binding the RadGrid?  How are you building the data source?  The usual culprit is rebuilding the data source on every post-back, instead of checking for Page.IsPostBack.
At this point I am not binding.  There will be 3 panels and I have a radion button list that must have a value or you cannot get to the next panel.  This works.  When I click on the Next button it fires this.

        protected void nextButton_Click(object sender, EventArgs e)
        {            
            GoToNextItem();
        }

Which calls this:

        private void GoToNextItem()
        {
            Telerik.Web.UI.RadPanelBar RadPanelBar1 = dvwOrders.FindControl("RadPanelBar1") as Telerik.Web.UI.RadPanelBar;
            Telerik.Web.UI.RadPanelItem thisRadPanelItem = RadPanelBar1.Items[0].Controls[0] as Telerik.Web.UI.RadPanelItem;

            int selectedIndex = thisRadPanelItem.Index;

            RadPanelBar1.Items[selectedIndex + 1].Selected = true;
            RadPanelBar1.Items[selectedIndex + 1].Expanded = true;
            RadPanelBar1.Items[selectedIndex + 1].Enabled = true;
            RadPanelBar1.Items[selectedIndex].Expanded = false;
        }

The value of selectedIndex is alway 0.   So I never get to panel 3.
ASKER CERTIFIED SOLUTION
Avatar of Bob Learned
Bob Learned
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Actually I figured out my problem.  By setting Selected = "True" on the aspx page, and changing the second line from this.

      Telerik.Web.UI.RadPanelItem thisRadPanelItem = RadPanelBar1.Items[0].Controls[0] as Telerik.Web.UI.RadPanelItem

to this.

Telerik.Web.UI.RadPanelItem thisRadPanelItem = RadPanelBar1.SelectedItem;

It now works. So I award you the points for your persistant effort.  Thank you.

That's funny, because I don't understand how that could work, and the other one doesn't...maybe because I don't have a clear picture of what you are working with.