The Syncfusion native Blazor components library offers 70+ UI and Data Viz web controls that are responsive and lightweight for building modern web apps.
.NET PDF framework is a high-performance and comprehensive library used to create, read, merge, split, secure, edit, view, and review PDF files in C#/VB.NET.
Would like to add rows to a data-bound grid by pasting rows from Excel. The underlying table has an identity primary key, which I would NOT copy a value into this field. Copy and paste works fine if the source and destination ranges are the same.
When I try add a range of values, I get:
"An unhandled exception of type 'System.IndexOutOfRangeException'
occured in system.data.dll
Additioanl information: Index 1 is not non-negative and below total rows count."
Is there sample of code of how this can be done? I would like the ability to create multiple rows at one time by copying from Excel.
ADAdministrator Syncfusion Team March 3, 2003 07:46 PM UTC
Hi Tom,
you need to handle the GridModel.ClipboardPaste event. You can subscribe to it via dataBoundGrid.Model.ClipboardPaste.
I am attaching some source code from the grid library that might be of use. What you will need to do is check if you need to add rows, and then call AddNew, add the data for the row and then EndEdit for every new row that needs to be added to the datasource.
You could also just add the data directly to the datasource and then just refresh the grid. In this case calling SuspendBinding/ResumeBinding and/or BeginUpdate/EndUpdate might be of use.
In a future version I would like to have this an option so that the grid automatically detects when it needs to add rows and act accordingly but for now you have to code this yourself.
Let me know if you run into trouble.
Stefan
TDThomas DomuratMarch 4, 2003 05:29 PM UTC
Would there be a VB code example? I would greatly appreciate it if you could post that if one exists. Thanks.