|
-
May 1st, 2007, 10:13 AM
#1
Thread Starter
Member
[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)
-
May 1st, 2007, 10:25 AM
#2
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"
-
May 1st, 2007, 10:31 AM
#3
Thread Starter
Member
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)
-
May 1st, 2007, 10:39 AM
#4
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.
-
May 1st, 2007, 11:10 AM
#5
Thread Starter
Member
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?
-
May 1st, 2007, 11:16 AM
#6
Re: [2005] Arg. out of range Error
Did you refresh schema on the object to update the databindings?
-
May 1st, 2007, 11:27 AM
#7
Thread Starter
Member
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.
-
May 1st, 2007, 11:31 AM
#8
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.
-
May 1st, 2007, 11:42 AM
#9
Thread Starter
Member
Re: [2005] Arg. out of range Error
Well, this is just a windows application. i didnt know you had html?
-
May 1st, 2007, 11:58 AM
#10
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.
-
May 1st, 2007, 01:21 PM
#11
Thread Starter
Member
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|