Link to home
Start Free TrialLog in
Avatar of etmendz
etmendz

asked on

'0' is not a valid value for 'value'. 'value' should be between 'minimum' and 'maximum'.

I am using .Net Framework 1.1 WinForms DataGrid.

Everytime I refresh the DataGrid, I get the error "'0' is not a valid value for 'value'. 'value' should be between 'minimum' and 'maximum'." especially when the query result is empty. What does this mean and how can I prevent it? Is this a bug in .Net?

Here's my VB.Net code:

                da.Fill(ds, "Monitor")
                dg.SetDataBinding(ds, "Monitor")

da is my DataAdapter. ds is a global variable of type DataSet. dg is my DataGrid. I initialize and bind ds to dg on Form load (using SetDataBinding()). The code above is how I refresh dg.

What causes the error "'0' is not a valid value for 'value'. 'value' should be between 'minimum' and 'maximum'." and is there a way to prevent it from happening?

On the side: Is there a better way of refreshing my DataGrid without having to call SetDataBinding() again?

Thank you in advance.
Avatar of Bob Learned
Bob Learned
Flag of United States of America image

How is the data grid initialized and configured?  Did you create an inherited control?  VB.NET or ASP.NET?  2002 or 2003?  Are you using any scroll bar controls?
Avatar of iboutchkine
iboutchkine

Do you use ErrorProviders? If yes check the validation values
also try to change
    da.Fill(ds, "Monitor")
    dg.SetDataBinding(ds, "Monitor")

to

    da.Fill(ds, "Monitor")
    dg.DataSource = ds.Tables("Monitor")
I assume that Monitor is your table
Avatar of etmendz

ASKER

Sorry I never got back to this sooner. Got stuck with other tasks. But I'm back with this problem (still)...

I used the DataGrid as is straight from the Toolbox.

This error happens only when my application is not the active window. If I keep my application window active, the error is never encountered.

:)
Avatar of etmendz

ASKER

I found a Microsoft article (I lost the URL) that said this is a known bug in the .Net Framework 1.0. It seems that it is still a problem in the .Net Framework 1.1. Or maybe not? I currently have both versions. I have configured my application to use 1.1.

Summarily, here's the situation:
* I fetch data from an SQL Server 2000 database.
* My DataGrid works well. I refresh my DataGrid on a regular basis (every 3 minutes) which works well , too.
* The error does not happen when the application is the active window.
* The error is encountered when the application is not the active window.
* I noticed that the error I reported here happens especially when the refresh results to an empty query result set.
* If the application window is left inactive for a long time (overnight), the DataGrid may itself becomes "dead" (does not refresh at all even if query results are expected; does not report errors). You'll need to restart the entire application to make it work again. This is intermittent but it happened.

I'd really appreciate if anyone can point me to a direction that completely solves this problem. The application in question cannot always be the active window in the server it is running. If it's a .Net bug (forever), an article that officially states so is appreciated.

Thanks in advance.
ASKER CERTIFIED SOLUTION
Avatar of ee_ai_construct
ee_ai_construct
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial