Select First Tab On PageLoad

10 posts, 1 answers
  1. Joe Weber
    Joe Weber avatar
    11 posts
    Member since:
    Jun 2012

    Posted 19 Jul 2010 Link to this post

    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>

     

     

     

     

  2. Yana
    Admin
    Yana avatar
    4554 posts

    Posted 20 Jul 2010 Link to this post

    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
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Joe Weber
    Joe Weber avatar
    11 posts
    Member since:
    Jun 2012

    Posted 20 Jul 2010 Link to this post

    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.
  5. Yana
    Admin
    Yana avatar
    4554 posts

    Posted 21 Jul 2010 Link to this post

    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
  6. Joe Weber
    Joe Weber avatar
    11 posts
    Member since:
    Jun 2012

    Posted 22 Jul 2010 Link to this post

    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.
  7. Yana
    Admin
    Yana avatar
    4554 posts

    Posted 28 Jul 2010 Link to this post

    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
  8. Joe Weber
    Joe Weber avatar
    11 posts
    Member since:
    Jun 2012

    Posted 28 Jul 2010 Link to this post

    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.
  9. Yana
    Admin
    Yana avatar
    4554 posts

    Posted 28 Jul 2010 Link to this post

    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
  10. Joe Weber
    Joe Weber avatar
    11 posts
    Member since:
    Jun 2012

    Posted 29 Jul 2010 Link to this post

    I'm not sure I exactly understand, can you give an example?
  11. Answer
    Yana
    Admin
    Yana avatar
    4554 posts

    Posted 04 Aug 2010 Link to this post

    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
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017