Link to home
Start Free TrialLog in
Avatar of SchoolTeacher54
SchoolTeacher54

asked on

Writing a value to a datagrid

Hello,

I have an application that allows user to add a new record in a datagrid view for a list of users; small table.

I check to see if the user 'forgot' to add certain fields required by my program. If they forgot the field I write a default value for them. The situation is this:

1. I ADD a new record
2. The user is entered just fine while leaving out these two fields that I'm checking for.
3. This code errors out telling me that:
An unhandled exception of type 'System.ArgumentOutOfRangeException' occurred in mscorlib.dll. Additional information: Index was out of range. Must be non-negative and less than the size of the collection.

I sure hope that you can help me!


Dim x
        x = Log_In_CredentialsDataGridView.SelectedRows(0).Cells(5).Value.ToString
        If x = "" Then Log_In_CredentialsDataGridView.SelectedRows(0).Cells(5).Value = 5

        Dim y
        y = Log_In_CredentialsDataGridView.SelectedRows(0).Cells(6).Value.ToString
        If y = "" Then Log_In_CredentialsDataGridView.SelectedRows(0).Cells(6).Value = 0
ASKER CERTIFIED SOLUTION
Avatar of David Johnson, CD
David Johnson, CD
Flag of Canada 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