[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1173
  • Last Modified:

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



0
Howard Katz
Asked:
Howard Katz
  • 4
  • 3
1 Solution
 
Bob LearnedCommented:
It would be helpful to know the exception...
0
 
Howard KatzDatabase Report DeveloperAuthor Commented:
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



0
 
Bob LearnedCommented:
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.
0
Get quick recovery of individual SharePoint items

Free tool – Veeam Explorer for Microsoft SharePoint, enables fast, easy restores of SharePoint sites, documents, libraries and lists — all with no agents to manage and no additional licenses to buy.

 
Howard KatzDatabase Report DeveloperAuthor Commented:
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.
0
 
Bob LearnedCommented:
You need to describe your process at a higher level, since you have provided too much detail, and not enough "big picture".  I would like to see this problem space from the 1000 meter view, rather than the 100 meter view.

How are you using the RadPanelBar?
0
 
Howard KatzDatabase Report DeveloperAuthor Commented:
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.

0
 
Bob LearnedCommented:
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.
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 4
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now