Tech
Forums
Jobs
Books
Events
Interviews
Live
More
Learn
Training
Career
Members
Videos
News
Blogs
Login
Sign Up
Ask Question
9
Reply
Index was out of range
mike Delvotti
Mar 8 2012 8:57 AM
1.9k
Reply
I'm getting the following message pop up even though the function works:
Index was out of range. Must be non-negative and less than the size of the collection. Parameter name:Index
I think it may be a null issue, but what would be the best way to overcome it on my code below. Basiclly i fill my dataset then databind it to a datagridview, then i hide columns i don't need to be seen in my datagrid, although the datagrid fills fine it throws the above message. my sample code below:
DataSet dsLookup = new DataSet();
dsLookup.ReadXml(response.GetResponseStream());
dataGridView1.DataSource = dsLookup.Tables[0];
dataGridView1.Columns["StockNumber"].DisplayIndex = 0;
dataGridView1.Columns["RegistrationNumber"].DisplayIndex = 1;
dataGridView1.Columns[0].Visible = false;
dataGridView1.Columns[1].Visible = false;
Upload Source Code
Select only zip and rar file.
Post
Reset
Cancel
Answers (
9
)
Next Recommended Forum
Clicking a button a website in c#
Filestreaming System.OutofMemoryException