ins.DeliveryNoteNo = dgv_Instalment.Rows[i].Cells["DeliveryNote"].Value.ToString();
but I ensure that I enter data to it
Message="Object reference not set to an instance of an object."
Source="Nursing"
StackTrace:
at Nursing.student_data.btn_edit_Click(Object sender, EventArgs e) in F:\New Folder\Visual Studio 2008\Projects\Nursing\Nursing\student_data.cs:line 628
at System.Windows.Forms.Control.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ButtonBase.WndProc(Message& m)
at System.Windows.Forms.Button.WndProc(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(Int32 dwComponentID, Int32 reason, Int32 pvLoopData)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
at System.Windows.Forms.Application.Run(Form mainForm)
at Nursing.Program.Main() in F:\New Folder\Visual Studio 2008\Projects\Nursing\Nursing\Program.cs:line 18
at System.AppDomain._nExecuteAssembly(Assembly assembly, String[] args)
at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()
InnerException:
Gaurish KumarPosted Nov 11, 2009, 1:23 AM
That error is coming due to the value of this
dgv_Instalment.Rows[i].Cells["DeliveryNote"].Value.ToString()
Value would be null.
Put a breakpoint and check the value of this.
Sam HobbsPosted Nov 10, 2009, 7:13 PM
The next thing to do is to determine what is null. You can do that by putting a breakpoint in the catch block; are you using try and catch? Do you know how to use a breakpoint? You can then hover your mouse over the various itmes to determine what is null. The problem could be any of the following:
- dgv_Instalment
- Rows[i]
- Cells["DeliveryNote"]
- Value
After determining which one of the above is null, then you can proceed to diagnose that specific problem.