PDA

View Full Version : اضافه کردن رکود جدید در radgridview



hamix666
پنج شنبه 21 بهمن 1395, 09:43 صبح
با سلام
من داخل پروژه یک radgridviwe قرار دادم که زمان لود فرم میاد اطلاعات رو از یک جدول در دیتا بیس می خونه تا اینجا مشکلی ندارم ضمنا نوجه فرمایید داخل این فرم اطلاعات دیگری هم هست حالا من می خوام داخل این گرید دقت بفرمایید داخل گرید نه دیتا بیس یک رکورد جدید اضافه کنم که زمانی که کاربر دکمه ثبت تغییرات فرم را زد اطلاعات داخل گرید تازه در دیتا بیس ذخیره بشه حالا مشکل اینجاست به محض این که کلید ایجاد رکرود جدید رو می زنم ارور می ده
کد ایجاد رکورد جدید : i = radgrsarmaye.RowCount + 1; radgrsarmaye.Rows.Add(i, cmbhamkar.Text, txtmali.Text, txtgheyrmali.Text, txtarzesh.Text);
i = i + 1;
txtsum.Text = Sumsarmayeadd();

متن ارور :

System.InvalidOperationException was unhandled
HResult=-2146233079
Message=RadListSource need a parameterless Constructor for <>f__AnonymousType0`4[[System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089],[System.Int32, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089],[System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089],[System.Int32, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]]
Source=Telerik.WinControls
StackTrace:
at Telerik.WinControls.Data.RadListSource`1.AddNew()
at Telerik.WinControls.UI.GridViewRowCollection.Add(O bject[] values)
at Omran.Form.Pishnehad.btnaddsarmaye_Click_1(Object sender, EventArgs e) in E:\proje\Omran\Omran\Form\Pishnehad.cs:line 135
at System.Windows.Forms.Control.OnClick(EventArgs e)
at DevComponents.DotNetBar.ButtonX.OnClick(EventArgs e)
at DevComponents.DotNetBar.ButtonX.OnMouseUp(MouseEve ntArgs e)
at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.DebuggableCallba ck(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
at System.Windows.Forms.UnsafeNativeMethods.DispatchM essageW(MSG& msg)
at System.Windows.Forms.Application.ComponentManager. System.Windows.Forms.UnsafeNativeMethods.IMsoCompo nentManager.FPushMessageLoop(IntPtr dwComponentID, Int32 reason, Int32 pvLoopData)
at System.Windows.Forms.Application.ThreadContext.Run MessageLoopInner(Int32 reason, ApplicationContext context)
at System.Windows.Forms.Application.ThreadContext.Run MessageLoop(Int32 reason, ApplicationContext context)
at System.Windows.Forms.Form.ShowDialog(IWin32Window owner)
at Omran.Form.Main.radgrid_CellDoubleClick(Object sender, GridViewCellEventArgs e) in E:\proje\Omran\Omran\Form\Main.cs:line 56
at Telerik.WinControls.UI.RadGridView.OnCellDoubleCli ck(Object sender, GridViewCellEventArgs e)
at Telerik.WinControls.UI.RadGridView.OnMouseDoubleCl ick(MouseEventArgs e)
at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
at System.Windows.Forms.Control.WndProc(Message& m)
at Telerik.WinControls.RadControl.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.DebuggableCallba ck(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
at System.Windows.Forms.UnsafeNativeMethods.DispatchM essageW(MSG& msg)
at System.Windows.Forms.Application.ComponentManager. System.Windows.Forms.UnsafeNativeMethods.IMsoCompo nentManager.FPushMessageLoop(IntPtr dwComponentID, Int32 reason, Int32 pvLoopData)
at System.Windows.Forms.Application.ThreadContext.Run MessageLoopInner(Int32 reason, ApplicationContext context)
at System.Windows.Forms.Application.ThreadContext.Run MessageLoop(Int32 reason, ApplicationContext context)
at Omran.Program.Main() in E:\proje\Omran\Omran\Program.cs:line 26
at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
at Microsoft.VisualStudio.HostingProcess.HostProc.Run UsersAssembly()
at System.Threading.ExecutionContext.RunInternal(Exec utionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionCon text executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionCon text executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()
InnerException:

ژیار رحیمی
یک شنبه 24 بهمن 1395, 14:23 عصر
شما radgrsarmaye.RowCount + 1 ; کردی که اشتباست رکورد جدید در دیتاگرید اندیس آن radgrsarmaye.RowCount است .

i = radgrsarmaye.RowCount;