Hello,
I have my mdi form. One of the child forms displays a datagrid of employee salaries.
On the mdi form l have a button called update. I want to pass the Employee ID number from the grid and display it in another form.
This is what l have done so far, but does not work.
In the salaries form (datagrid form) i have this code.
Code:/**************************** Set a variable and store the ID number in this value when the user clicks the grid row ****************************/ private string employeeNumber; employeeNumber = grdSalaries[grdSalaries.CurrentRowIndex,0]; /****************************************************** *For sending this employeenumber to the update form * to update the correct employee details * ****************************************************/ public string getEmployeeNumber { get { return employeeNumber; } set { value = employeeNumber; } }
In the update form l have this code in the form load.
employeeNumber = parent.getEmployeeNumber;
I have declared these above the constructor
private string employeeNumber;
frmSalaries parent;
My constructor is listed below
The error message is belowCode:public frmUpdateEmployee(frmSalaries form) { // // Required for Windows Form Designer support // InitializeComponent(); // // TODO: Add any constructor code after InitializeComponent call // parent = form; }
An unhandled exception of type 'System.NullReferenceException' occurred in payrole.exe
Additional information: Object reference not set to an instance of an object.
The way the program works is the main control buttons are displayed in the mdi, when you click on show salaries it displays the form with the grid. The user will click once on the grid and then click on the update button on the mdi form. This will then display another form which is passed the ID number so l know who i have to update.
Many thanks in advance,
Steve




Reply With Quote