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

Select First Tab On PageLoad

9 Answers 163 Views
TabStrip
This is a migrated thread and some comments may be shown as answers.
Joe Weber
Top achievements
Rank 2
Joe Weber asked on 19 Jul 2010, 07:44 PM
I am using the RadTabStrip and dynamically setting the tab values from a database.  Everything works fine except on PageLoad.  Then it displays with no tab selected.  How do I make the first tab to display as selected?  This is using VB...

Thanks for any help.

 

<asp:SqlDataSource ID="SqlDataSource1" runat="server"

 

        ConnectionString="<%$ ConnectionStrings:CNIPanelTestConnectionString %>"

 

 

 

         SelectCommand="SELECT [TabName], [TabID] FROM [TabType]">

 

 

 

</asp:SqlDataSource>

 

 


<
telerik:RadTabStrip ID="RadTabStrip1" runat="server"

 

 

 

        DataSourceID="SqlDataSource1" DataTextField="TabName" DataValueField="TabID"

 

 

 

        Skin="Blue" EnableEmbeddedSkins="False">

 

 

 

</telerik:RadTabStrip>

 

 

 

 

9 Answers, 1 is accepted

Sort by
0
Yana
Telerik team
answered on 20 Jul 2010, 08:06 AM
Hi Joe Weber,

You just need to set SelectedIndex property of the tabstrip:

<telerik:RadTabStrip ID="RadTabStrip1" runat="server"
DataSourceID="SqlDataSource1" DataTextField="TabName" DataValueField="TabID"
Skin="Blue" EnableEmbeddedSkins="False" SelectedIndex="0">
</telerik:RadTabStrip>

Greetings,
Yana
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Joe Weber
Top achievements
Rank 2
answered on 20 Jul 2010, 04:24 PM
Thank you very much for your quick response; it worked perfectly.

If I may ask a similar question:  I am also using RadPanelBars with the TabStrip.  How do I select a specific RadPanel Item?  For instance, on PageLoad, Tab 1 on the tab Strip is displayed as selected which will display RadPanelBar1.  Now I want to show the first item on the RadPanelBar as selected.

Thank you again for any help with this.
0
Yana
Telerik team
answered on 21 Jul 2010, 03:32 PM
Hi Joe,

Please use the following code line to select the first item:

RadPanelBar1.Items[0].Selected = true;

Kind regards,
Yana
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Joe Weber
Top achievements
Rank 2
answered on 22 Jul 2010, 05:16 PM
Again, thank you for your prompt reply.  I am new to this so forgive my questions...

I tried your last suggestion but I get the following:

Index was out of range. Must be non-negative and less than the size of the collection.
Parameter name: index

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.ArgumentOutOfRangeException: Index was out of range. Must be non-negative and less than the size of the collection.
Parameter name: index

Source Error:

Line 13:             RadTabStrip1.TabIndex = 0 'set selected tab to first tab
Line 14:             RadPanelBar1.Visible = True
Line 15: RadPanelBar1.Items(0).Selected = True 'set selected PanelBar item to first item
Line 16: RadPanelBar2.Visible = False Line 17: RadPanelBar3.Visible = False

Thank you for any help.
0
Yana
Telerik team
answered on 28 Jul 2010, 09:34 AM
Hi Joe Weber,

How exactly you populate the panelbar? The error shows that you select an item before the items are actually loaded. Please send us more information about your scenario.

Regards,
Yana
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Joe Weber
Top achievements
Rank 2
answered on 28 Jul 2010, 03:49 PM
Thank you for your reply.  Yes, I agree, I am trying to select an item before it is loaded.  But how to load it first and then show it as selected?

What I am trying to do is display a tabbed list of groups of physicians.  When the page loads it should show the first group and the first physician in that group as selected.  The tabStrip and PanelBar are filled from an SQL database.  The DB has two tables, one for the groups and one for the Physicians.

Thank you for any help.
0
Yana
Telerik team
answered on 28 Jul 2010, 04:08 PM
Hi Joe ,

You can try to subscribe to DataBound (not ItemDataBound) event of the panelbar and select the first item in its handler.

Kind regards,
Yana
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Joe Weber
Top achievements
Rank 2
answered on 29 Jul 2010, 03:28 PM
I'm not sure I exactly understand, can you give an example?
0
Accepted
Yana
Telerik team
answered on 04 Aug 2010, 10:00 AM
Hi Joe,

I've attached a simple page to demonstrate this approach, download it and give it a try.

Best wishes,
Yana
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Tags
TabStrip
Asked by
Joe Weber
Top achievements
Rank 2
Answers by
Yana
Telerik team
Joe Weber
Top achievements
Rank 2
Share this question
or