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

Update another cellvalue from CellValidating

5 Answers 61 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Matthew
Top achievements
Rank 1
Matthew asked on 19 Oct 2011, 05:06 AM
I have setup a site where users paste a specific format of data into a radGrid from Excel.

What I want is to update the last Cell on each Row with a String that is returned by a Linq query. Ideally this would be done both from the CellValidating and PastingCellClipboardContent events...

For the CellValidating event...I tried getting the ParentRow and referencing the last Cell by index number, but this failed.

As for PastingCellClipboardContent...I'm really not sure how to get anything useful from this event.

How would I go about doing this?

5 Answers, 1 is accepted

Sort by
0
Maya
Telerik team
answered on 19 Oct 2011, 07:17 AM
Hello Matthew,

I would recommend you to update the underlying data item and its corresponding property, not the value of the cell. You can get the item in CellValidatingEvent as:

private void clubsGrid_CellValidating(object sender, GridViewCellValidatingEventArgs e)
        {
            Club club = e.Row.Item as Club;
        }
 
While in PastingCellClipboardContent:
private void clubsGrid_PastingCellClipboardContent(object sender, GridViewCellClipboardEventArgs e)
        {
            GridViewCellInfo cellInfo = e.Cell as GridViewCellInfo;
            Club club = cellInfo.Item as Club;
        }

Thus once you have the item (club in this case), you could update the property bound to the last column.
 

Kind regards,
Maya
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

0
Matthew
Top achievements
Rank 1
answered on 19 Oct 2011, 05:00 PM
Thanks Maya.

When I implement this it seems to work about 80% of what I need it to do.  It seems to work fine from the CellValidating, but when attempting to use the following logic in the PastingCellClipboardContent event it does not update the other cell value.

For example...

WebService.GetCustomerAsync(SLANumber); //this saves the customer # into a variable called custLookup
...
club.Customer = custLookup; //this should set the last cell on the row to the value retrieved in the async call above

When viewing the grid, the Customer column is blank.  It's like it updated the club.Customer field but did not reflect the change on the grid.
0
Matthew
Top achievements
Rank 1
answered on 19 Oct 2011, 05:08 PM
I implemented the INotifyPropertyChanged interface and fixed PART of this issue...
0
Maya
Telerik team
answered on 20 Oct 2011, 09:52 AM
Hi Matthew,

I am attaching a sample project illustrating how you can update a property of an item on pasting the clipboard content. Please take a look at it for a reference and let me know in case of any misunderstandings.
 

Greetings,
Maya
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

0
Satish
Top achievements
Rank 1
answered on 13 Dec 2011, 03:59 PM
i am updating all the other rows cells by using  radgridview datacollection iteams on cellvalidating event handler. but after the valdation completes i am not able to see the updated values in all the rows. If i click on each cell then update values appears.
Any solution to this pleas let me know.
Tags
GridView
Asked by
Matthew
Top achievements
Rank 1
Answers by
Maya
Telerik team
Matthew
Top achievements
Rank 1
Satish
Top achievements
Rank 1
Share this question
or