Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3806068
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T14:46:38+00:00 2026-05-19T14:46:38+00:00

I have a simple application with a GridView bound to a LinqDataSource and a

  • 0

I have a simple application with a GridView bound to a LinqDataSource and a DetailView that displays a row from the GridView when it’s selected. This works as expected. But now I’m placing the GridView and DetailView in separate TabPanels in an asp.net ajax Tab Control.

<asp:ToolkitScriptManager ID="ToolkitScriptManager1" runat="server">
</asp:ToolkitScriptManager>
<asp:TabContainer ID="CourseFinder" runat="server" ActiveTabIndex="0">
    <asp:TabPanel ID="ResultsTab" runat="server" HeaderText="Results" > 
    </asp:TabPanel>
    <asp:TabPanel ID="DetailTab" runat="server" HeaderText="Detail">
    </asp:TabPanel>
</asp:TabContainer>

and my code behind file

protected void Page_Load(object sender, EventArgs e)
{
    CourseFinder.Tabs[0].Controls.Add(Results);
    CourseFinder.Tabs[1].Controls.Add(DetailsView1);
}

When I run the page I’m getting

[ArgumentOutOfRangeException: Index was out of range. Must be non-negative and less than 
the size of the collection.
Parameter name: index]
System.Collections.ArrayList.get_Item(Int32 index) +7483656
System.Web.UI.WebControls.GridViewRowCollection.get_Item(Int32 index) +13
_Default.Results_SelectedIndexChanged(Object sender, EventArgs e) in c:\Documents and   
Settings\Administrator\My Documents\Visual Studio 
2008\WebSites\WebSite1\Default.aspx.cs:35
...

The line of code getting the error is the one attempting to get the SelectedIndex from the GridView and update my DetailView.

 GridViewRow row = Results.Rows[Results.SelectedIndex];

I stepped through the code with the debugger and SelectedIndex is not negative and it’s not larger than the number of rows in the GridView. So I’m confused why simply placing the controls inside a Tab is causing this error?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-19T14:46:39+00:00Added an answer on May 19, 2026 at 2:46 pm

    Are you adding the panels dynamically? [Karel]

    Yes…

    Is there another way to get the tabs
    to display without adding them
    dynamically? I couldn’t get them to
    display otherwise [Matt Phillips]

    Don’t do that! It makes things much more complicated.
    You could add your GridView/DetailsView to an UserControl and add this to the ContentTemplate of the TabPanel.

    Here is a good tutorial on how to lazy-load TabPanels:
    http://mattberseth.com/blog/2007/07/how_to_lazyload_tabpanels_with.html

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a simple message box in a WPF application that is launched as
I have a GridView control in an Asp.net application, that has a <asp:buttonField> of
I have a simple application that consists of a HSlider and a list that
I have a simple test application with a GridView containing an array of buttons,
Hey i have a simple ASP.NET application Table with this schema: id | Owner
I have a GridView in my Android application that has a number of ImageViews
I have simple application. To be more specific this is Visual Studio Addin. Client
HI, I have simple application which copy text from a textbox and paste it
I have a simple application with the following code: FileInfo[] files = (new DirectoryInfo(initialDirectory)).GetFiles();
I have a simple application using netbeans for developing and maven for building et

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.