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;