Quantcast
Channel: Windows Forms Data Controls and Databinding forum
Viewing all articles
Browse latest Browse all 2535

DataGridView.DataSource throwing Index was out of range exception

$
0
0

 

Hello all,

 

I'm having a problem with DataGirdView. 

I am using a BindingSource object to bind that DataTable object to the DataGridView and I get the following exception thrown on the line I set the DataGirdView.DataSource = BindingSource object:-

 

Index was out of range. Must be non-negative and less than the size of the collection.\r\nParameter name: index"} System.Exception {System.ArgumentOutOfRangeException}

 

Heres the code:-

 

Code Snippet

source =

newBindingSource();

source.DataSource = dset.Tables[0];

resultsGrid.DataSource = source;

 

 

I am at a loss as to why this is happening as the the DataSet contains 1 table and the Table contains 1 row.

After it throws the exception the app binds the table to DataGridView as expected 

 

Does anyone know why this would be happening ??

 

Thanks,
Sean


Viewing all articles
Browse latest Browse all 2535

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>