Results 1 to 11 of 11

Thread: [2005] Arg. out of range Error

  1. #1

    Thread Starter
    Member
    Join Date
    Apr 2007
    Posts
    50

    [2005] Arg. out of range Error

    The second line of the code is giving me an "ArgumentOutOfRangeException was handled". Then it says:
    "Index was out of range. Must be non-negative and less than the size of the collection.
    Parameter name: index"

    The number is non-negative so i dont know why it would be giving me this?

    Code:
    Me.DataGridView1.Item(0, 0).Value = ds.Tables("SheldonVB").Rows(0).Item(0)
    Me.DataGridView1.Item(0, 1).Value = ds.Tables("SheldonVB").Rows(0).Item(1)

  2. #2
    Banned timeshifter's Avatar
    Join Date
    Mar 2004
    Location
    at my desk
    Posts
    2,465

    Re: [2005] Arg. out of range Error

    Eh... looking at that, I'm going to guess you're trying to suck in data from a database... why not just use the smart tags and configure it as a databound object? No mess with that stuff.

    Besides, GridViews aren't 2D arrays... they're rows. So you'd need to create an object and set it equal to what you want...
    Dim myLbl as Label = DataGridView1.Rows(0).FindControl("Label1")
    myLbl.Text = "blah"

  3. #3

    Thread Starter
    Member
    Join Date
    Apr 2007
    Posts
    50

    Re: [2005] Arg. out of range Error

    yea, i am trying to get data from the database. How would i use the smart tags to fill the gridview with my data? (sorry, kind of new to this)

  4. #4
    Banned timeshifter's Avatar
    Join Date
    Mar 2004
    Location
    at my desk
    Posts
    2,465

    Re: [2005] Arg. out of range Error

    Click on the object. There's a little black arrow near the top right corner. Click that. The panel that appears is the smart tag. Where it says Select Data Source, just drop that down and hit New Data Source. Assuming your connection string is right, just go through the wizard and it'll take care of everything for you.

  5. #5

    Thread Starter
    Member
    Join Date
    Apr 2007
    Posts
    50

    Re: [2005] Arg. out of range Error

    ah i see. ok when i select the binding source and click preview data, it shows me the data that i want to see in the grid view but when i run the program it is empty?

  6. #6
    Banned timeshifter's Avatar
    Join Date
    Mar 2004
    Location
    at my desk
    Posts
    2,465

    Re: [2005] Arg. out of range Error

    Did you refresh schema on the object to update the databindings?

  7. #7

    Thread Starter
    Member
    Join Date
    Apr 2007
    Posts
    50

    Re: [2005] Arg. out of range Error

    Im sorry I am new at this. I dont know how to do that. But, what do i need to select from the box that shows up: the binding source or the data set?

    i already have it where the data will show up in text boxes one record at a time. i can navigate through them using buttons.

  8. #8
    Banned timeshifter's Avatar
    Join Date
    Mar 2004
    Location
    at my desk
    Posts
    2,465

    Re: [2005] Arg. out of range Error

    Go to the source of your page... the HTML code, not the VB stuff. Find your data source, and post that entire tag... everything between the <asp:SqlDataSource> and the </asp:SqlDataSource> tags.

  9. #9

    Thread Starter
    Member
    Join Date
    Apr 2007
    Posts
    50

    Re: [2005] Arg. out of range Error

    Well, this is just a windows application. i didnt know you had html?

  10. #10
    Banned timeshifter's Avatar
    Join Date
    Mar 2004
    Location
    at my desk
    Posts
    2,465

    Re: [2005] Arg. out of range Error

    Ahh.. see, I don't work with databases and applications. I'm a web developer... so everything I do involves HTML... My apologies.

  11. #11

    Thread Starter
    Member
    Join Date
    Apr 2007
    Posts
    50

    Re: [2005] Arg. out of range Error

    ITs no problem. thanks for your time

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width