This is a migrated thread and some comments may be shown as answers.

Excel pasting issue

1 Answer 39 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Frank
Top achievements
Rank 1
Frank asked on 24 Feb 2015, 11:01 PM
In each cell of my gridview combobox column, I have 2 items ("abc" and "xyz").  In the Excel spread sheet, I have 2 rows, but I am not getting the result when I paste those 2 row into telerik gridview, here are the scenario:

1. If first row is "abc" and second row is "xyz", result is ok,
2. If first row is "abc" and second row is "fgh" which "fgh" is not in any of the combobox items, when I paste into gridview, I get "abc" on both rows!

So it seems that when I paste a value that does not exist in the combobox, it simply pick the "prior" row data (which is valid) and "stuff" it in.  Is there anyway to get "blank" when the value does not exist in the combobox, instead of this "fake wrong data" being stuff in?

The reason is that the person who pasted does not know that he just pasted a "dirty data" into the grid.  But by making it "blank", the person can see quickly on the screen that there is a "blank" and thus need to pick a valid value.

I did try to find a way to "validate" the data with the copypaste event of the grid, but the problem is that it seems there is no "finditembytext / value" method like your ASP.NET datagrid.  I was thinking that if during the "pasting" event, I can see if the "copy" value exist in the combobx column (datasource) and if does not exist, 'cancel" the operation.  But again, I don't know what is the "method" to call within the gridview comboboxcolumn object.

thx!

1 Answer, 1 is accepted

Sort by
0
Dimitrina
Telerik team
answered on 25 Feb 2015, 05:01 PM
Hello,

In order to get the row corresponding to a particular item, I would suggest you using the GetRowForItem method. Generally, the way to control the pasting scenarios is subscribing for the the Pasting and PastingCellClipboardContent events.

You can find some more test scenarios on the following example from our online github repository: CopyPasteFunctionality. Although GitHub is a very well-known platform we saw a better and easier approach for reviewing our examples developing our brand new SDK Samples Browser. You can install it and then use it to review the examples.

Regards,
Dimitrina
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
Tags
GridView
Asked by
Frank
Top achievements
Rank 1
Answers by
Dimitrina
Telerik team
Share this question
or