Link to home
Start Free TrialLog in
Avatar of kshumway
kshumwayFlag for United States of America

asked on

Datagridview scrolling / tabbing issue

I am unable to  scroll or arrow down the through all the rows of data in my datagridview.  After some point, I get the following error

Value of '434' is not valid for 'Value'. 'Value' should be between 'minimum' and 'maximum'.
Parameter name: Value

What do I need to do so that I can scroll  and / arrow down to the last row in the datagridview?  

Thank you in advance for your  help!
Avatar of gamarrojgq


Are you using Custom Column Types? or adding data on the fly? did your datasource any constraint for numeric columns?

Try to define if there is a particulary Row when the errors occurs and try to look for a column with value 434
Avatar of kshumway


I am not using any custom column types as far as I know.  I use the same datasource for another view of the data where I display one record at a time and use previous / next buttons to step through the records.  That works fine.  Below is the code I use to fill the dataviewgrid.
Dim sSQL As String
        Dim dtCC As New DataTable


        sSQL = "SELECT * FROM HDCustCorrespondence WHERE HDTrackNo = " & ltrackingNo & " ORDER BY CCDateTime Desc"
        Dim daCC As New SqlClient.SqlDataAdapter(sSQL, conn)
            daCC.Fill(dsCC, "Correspondence")
        Catch ex As Exception
        End Try
        dtCC = dsCC.Tables(0)
        CustCorrespondGrid.DataGridView1.DataSource = dsCC.Tables(0)

Open in new window

Avatar of Nasir Razzaq
Do you have any validation setup for the grid?
A "work-around" would be to handle the DataGridView DataError event. (NOTE: this means the errors will be supressed. Do this if you are SURE your data is ALWAYS valid).

Private Sub DataGridView1_DataError(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewDataErrorEventArgs) Handles DataGridView1.DataError
    'you can then indicate which row generated the error
    DataGridView1.Rows(e.RowIndex).ErrorText = "Error"
End Sub

Open in new window

I do not have any validation set on the datagrid.  I added the line of code above, but I am still getting the error.  The value seems to be changing.  It is not always 434.
Did you datagridview allow new Records? perhaps when you press Page Down and goes to the End Row is trying to add a new row and maybe a column is setting a default value and there is when you error occurs
No - The datagridview is readonly.  
Avatar of kshumway
Flag of United States of America image

Link to home
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Figured out the solution via trial and error.