View Full Version : ASP.NET: Index was out of range

06-26-2004, 05:46 PM
I'm getting "Index was out of range. Must be non-negative and less than the size of the collection." error. Does anybody know what is it?

I have a sub which filters data from a table and then binds them to a datagrid. Something like -
'Build SQL string
da = New OleDbDataAdapter(SQL, ConnString)
da.Fill(ds) 'ds is a dataset
Session("View") = ds.Tables(0).DefaultView
dataGrid.DataSource = Session("View")

I can't debug this because it's working fine on my computer in devel. mode.
It also works when I enter a filter criteria on the server. But it doesn't when there is no criteria entered. Then I get the abovementioned message. I assume this is something related to the postback.

Any ideas? Thanks

06-27-2004, 12:58 PM
Session("View") = ds.Tables(0).DefaultView
throw new exception (ds.Tables.count.tostring)
end try

and you will see if you table collection is empty