Howard Katz
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[selecte dIndex + 1].Selected = true;
RadPanelBar1.Items[selecte dIndex + 1].Expanded = true;
RadPanelBar1.Items[selecte dIndex + 1].Enabled = true;
RadPanelBar1.Items[selecte dIndex].Ex panded = false;
}
}
Since my RadPanelBar is inside a formview I need for use FindControl to see it.
Telerik.Web.UI.RadPanelBar RadPanelBar1 = dvwOrders.FindControl("Rad PanelBar1" ) as Telerik.Web.UI.RadPanelBar ;
Telerik.Web.UI.RadPanelIte m thisRadPanelItem = RadPanelBar1.Items[0].Cont rols[0] as Telerik.Web.UI.RadPanelIte m;
If then I try to do this, I get an error
int selectedIndex = RadPanelBar1.SelectedItem. Index;
Thank you
Howard
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.
if ((selectedIndex + 1) < RadPanelBar1.Items.Count)
{
RadPanelBar1.Items[selecte
RadPanelBar1.Items[selecte
RadPanelBar1.Items[selecte
RadPanelBar1.Items[selecte
}
}
Since my RadPanelBar is inside a formview I need for use FindControl to see it.
Telerik.Web.UI.RadPanelBar
Telerik.Web.UI.RadPanelIte
If then I try to do this, I get an error
int selectedIndex = RadPanelBar1.SelectedItem.
Thank you
Howard
It would be helpful to know the exception...
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
int selectedIndex = RadPanelBar1.SelectedItem.
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.
ASKER
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("Rad PanelBar1" ) as Telerik.Web.UI.RadPanelBar ;
Telerik.Web.UI.RadPanelIte m thisRadPanelItem = RadPanelBar1.Items[0].Cont rols[0] as Telerik.Web.UI.RadPanelIte m;
int selectedIndex = thisRadPanelItem.Index;
RadPanelBar1.Items[selecte dIndex + 1].Selected = true;
RadPanelBar1.Items[selecte dIndex + 1].Expanded = true;
RadPanelBar1.Items[selecte dIndex + 1].Enabled = true;
RadPanelBar1.Items[selecte dIndex].Ex panded = false;
}
The value of selectedIndex is alway 0. So I never get to panel 3.
protected void nextButton_Click(object sender, EventArgs e)
{
GoToNextItem();
}
Which calls this:
private void GoToNextItem()
{
Telerik.Web.UI.RadPanelBar
Telerik.Web.UI.RadPanelIte
int selectedIndex = thisRadPanelItem.Index;
RadPanelBar1.Items[selecte
RadPanelBar1.Items[selecte
RadPanelBar1.Items[selecte
RadPanelBar1.Items[selecte
}
The value of selectedIndex is alway 0. So I never get to panel 3.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Actually I figured out my problem. By setting Selected = "True" on the aspx page, and changing the second line from this.
Telerik.Web.UI.RadPanelIte m thisRadPanelItem = RadPanelBar1.Items[0].Cont rols[0] as Telerik.Web.UI.RadPanelIte m
to this.
Telerik.Web.UI.RadPanelIte m thisRadPanelItem = RadPanelBar1.SelectedItem;
It now works. So I award you the points for your persistant effort. Thank you.
Telerik.Web.UI.RadPanelIte
to this.
Telerik.Web.UI.RadPanelIte
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.