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

first Row Deleting Problem

19 Answers 525 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Rehan
Top achievements
Rank 1
Rehan asked on 14 Jun 2008, 06:44 AM
i was working wd telerik Q3 2007 due to deleting Cresh problem and some others issues i jst switched to Q1 2008 SP1. bt i still found an error. as Row deleting/RowDeleted function has been replaced with RowChanging/RowChanged.we i hve only one row and i m gonna delete that row RowChanging Event Works Fine bt i could not be able to catch RowChanged Event as i want to do some work on RowChanged as well. Is any other event that could allow me not to much changes in my Code ?

19 Answers, 1 is accepted

Sort by
0
Kiril
Telerik team
answered on 16 Jun 2008, 03:40 PM
Hi Rehan ,

I'm not sure I completely understand your scenario.

In Q1 2008, the event system of the RadGridView has been changed. In older versions, there were a variety of events for the different operations that can be performed on the data stored in the grid. These have been replaced by one event, which is raised with different event args.

This means that you will not have to place your code in the handler for a different event. Place all of the code you need to perform after a deletion of a row in the handler of the RowChanging event. You only need to verify that the event arguments indicate that a row has been deleted.

If you have any further questions, please contact me.

All the best,
Kiril
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
Rehan
Top achievements
Rank 1
answered on 17 Jun 2008, 10:38 AM
dear i think you cant understand my Problem. ok let me give u the example code .

 

Private

Sub RadGridView1_RowsChanging(ByVal sender As Object, ByVal e As Telerik.WinControls.UI.GridViewCollectionChangingEventArgs) Handles RadGridView1.RowsChanging

''' MsgBox("step row changing")

If e.Action = Telerik.WinControls.Data.NotifyCollectionChangedAction.Remove Then

Dim cCancel As DialogResult

cCancel = MessageBox.Show(

"Are you sure you want to delete the selected row ?", SystemConfiguration.MessageTitle, MessageBoxButtons.YesNo, MessageBoxIcon.Question)

If cCancel = DialogResult.Yes Then

If Me.RadGridView1.Rows(CurrentRow).IsCurrent = False Or Me.RadGridView1.Rows(CurrentRow).Cells(ItemNumberColumn).Value.ToString() = "" Then

Else

UpdateITMTable.SubQtyInEachItemLine(Me.RadGridView1.Rows(CurrentRow).Cells(ItemNumberColumn).Value, Me.RadGridView1.Rows(CurrentRow).Cells(QuantityColumn).Value)

CurrentRowDeleted =

True

End If

Else

e.Cancel = True

End If

End If

End Sub


this is wut i m doing behid the rowchanging event ... here if we have only 1 row ... row changing event will occured and i say yeah i want to delete the row and my code behind deletion do some calculations on grid rows count. if i call it here then rows will be still 1 as this event is in process.

the calculation code only needs to call at RowChanged Event as you ppl also mention that in Q1 2008

RowDeleting

/RowDeleted events have been replaced by RadGridView

RowsChanging

/RowsChanged events.

the only problem is that if we have only 1 row in gridview we cant be able to catch RowChanged Event.bt if we have more then one row it works f9.

0
Kiril
Telerik team
answered on 17 Jun 2008, 12:48 PM
Hi Rehan ,

Thank you for writing.

I managed to reproduce the issue you described, and I thank you for bringing our attention to the issue. This issue will be addressed for the Q2 2008 release. For the time being, You'll be able to place your code which is meant to be executed in the handler of the CurrentRowChanged after row deletion the RowsDeleting event. 

Let me know whether this solves the issue in your scenario.

Your Telerik points have been updated. If you have any further questions, please let me know.

Kind regards,
Kiril
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
Rehan
Top achievements
Rank 1
answered on 18 Jun 2008, 03:51 AM
hi Kiril,
dear i already tried to solve this issue wd CurrentRowChanged handler bt just failed it gives an error
"This row has been removed from a table and does not have any data.  BeginEdit() will allow creation of new data in this row."


at CurrentRowChanged event i observed it did not decrease the radGrid Row.
i think i need to change my code for the purpose :) ...


0
Kiril
Telerik team
answered on 18 Jun 2008, 01:41 PM
Hi Rehan ,

Excuse me for taking so long to resolve this issue. The issue you reported has been added to our TODO list and will be resolved in one of the future releases. For the time being, there's another method you can use to execute logic following the deletion of a row - subscribe to the ListChanged method the datasource of the grid control.

this.radGridView1.DataSource = customersBindingSource;  
customersBindingSource.ListChanged += new ListChangedEventHandler(customersBindingSource_ListChanged); 

In the handler of this event, you can place the code below, to let you know when an item has been deleted:

void customersBindingSource_ListChanged(object sender, ListChangedEventArgs e)  
{  
    switch (e.ListChangedType)  
    {  
        case ListChangedType.ItemDeleted:  
            //your code here  
            break;  
    }  

I hope this helps. If you have further questions, please let me know.

Regards,
Kiril
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
David
Top achievements
Rank 1
answered on 15 Aug 2008, 09:43 AM
Hi ,

I have encountered the same issue which my last row deletion event never get the chance to fire.The suggested method is taggng on bindingsource whch i am not using. Any alternative ways for non-binding  datasource.

David
0
Jack
Telerik team
answered on 15 Aug 2008, 02:59 PM
Hello David,

Thank you for this question.

I confirm that in the latest release of RadGridView the RowsChanged event isn't fired when there is only one row. This issue will be addressed in our upcoming service pack.

To work around the issue you could process the RowChanging event instead. Consider the code below:

void radGridView1_RowsChanging(object sender, GridViewCollectionChangingEventArgs e) 
    if (e.Action == NotifyCollectionChangedAction.Remove) 
    { 
    } 


I hope this helps you. Please let me know if you need further assistance.

Regards,
Jack
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
David
Top achievements
Rank 1
answered on 15 Aug 2008, 03:14 PM
Hi Jack,

That will not help as after the last row deletion, i need to trigger a function to recalcute the figures. At row changing, the grid row count is still at 1 and only after this event than that row data is clear.

Plus i encountered grid index=-1 error after i delete the all grid  rows and edit one column of the new row i created. Please advise.
0
Jack
Telerik team
answered on 15 Aug 2008, 04:01 PM
Hi David,

Thank you for getting back to me.

Our next service pack will be released in 10 days from now and it will address this issue. If the issue is a show stopper for you, please send me a sample project that reproduces it (you can do so in a support ticket). I will try to find a solution for you.

Do not hesitate to write me if you have other questions.
 

Greetings,
Jack
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
ewart
Top achievements
Rank 1
answered on 21 Nov 2008, 06:27 AM

Jack, I've just spent an hour on this using the latest version of controls and my experience is that the _RowsChanged event still does not work properly.  Regardless of row number or how many rows are left, when removing a row it fills the NewItems[] collection with one row - it should fill the OldItems and it's not even the row I deleted!  Very frustrating.

Can you confirm this is still an existing bug with the grid, or is this something new to report?

Regards
  Ewart.


0
Jack
Telerik team
answered on 21 Nov 2008, 04:26 PM
Hello ewart,

Thank you for bringing our attention to this issue.

I understand your frustration and to my regret I have to can confirm that it still exists. I have added the issue with high priority in our TODO for the upcoming service pack. Your Telerik points have been updated.

Don't hesitate to contact us if you have other questions.


Greetings,
Jack
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Support
Top achievements
Rank 1
answered on 02 Dec 2008, 11:01 AM
Hi, any news on a fix for this?  I'm suffering with the same problem.
0
Jack
Telerik team
answered on 04 Dec 2008, 07:34 PM
Hello Rehan,

The RowsChanged event is fired after removing the row in this case. So, it is not possible to get an instance to the row, because it is already destroyed. Because of all this, the OldItems array is empty. The NewItems array contains the new row at the specified position. This behavior is by design.

I would suggest using the RowsChanging event to get the row that is being deleted. If you need any further assistance I will be glad helping you.
 

All the best,
Jack
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Ryan
Top achievements
Rank 1
answered on 14 Dec 2008, 03:49 AM
I am experiencing a similar situation and am very much in need of a solution.

I'm setting the datasource of my radgridview to a datatable. When I remove the first row of the datagrid programatically from the datatable....the datasource is updated accurately...but the gridview does not update...so therefore the gridview is out of sync with the datasource.

(I'm using RadControls for WinForms...Version 7.1.1.0)

Is there a work around for this yet?

Thanks,
Ryan

0
Jack
Telerik team
answered on 15 Dec 2008, 10:02 AM
Hello Ryan,

Thank you for your question.

Yes, we did have this problem, add it has been addressed since. I tired it again with the latest version and the grid updates properly. I would recommend trying the Q3 2008 SP1 version of RadControls for WinForms. We will highly appreciate any feedback you have.

Do not hesitate to write us if you have other questions.

Regards,
Jack
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Ryan
Top achievements
Rank 1
answered on 22 Dec 2008, 09:13 PM
I have upgraded to Q3 and now when I try to delete the first row in my grid I get this exception....

"Exception has been thrown by the target of an invocation."

0
Jack
Telerik team
answered on 23 Dec 2008, 05:01 PM
Hello Ryan,

Thank you for getting back to us.

I need more information to locate the source for this issue. Could you, please open a support ticket and send me your application that reproduces the issue? This will help me find a proper solution for you.

Thank you in advance for your cooperation.
 

Sincerely yours,
Jack
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Jorge Mendoza Martinez
Top achievements
Rank 1
answered on 09 Jun 2010, 06:51 PM
I have this problem to I am using the version 2010 Sp1.
I try to Delete the first row and after delete the row present a error say: Index 0 is either negative or above rows count., 

 Private Sub rgvWidth_RowsChanging(ByVal sender As System.Object, ByVal e As Telerik.WinControls.UI.GridViewCollectionChangingEventArgs) Handles rgvWidth.RowsChanging
        Try
            Select Case e.Action
                Case Telerik.WinControls.Data.NotifyCollectionChangedAction.Remove
                    If CType(e.OldItems(0), GridViewDataRowInfo).Cells("Id").Value <> 0 Then
                       ' Delete the row in the data base and reload all the Data
                        RemoveMatedSetWidth(CType(e.OldItems(0), GridViewDataRowInfo).Cells("Id").Value)
                    End If
            End Select
        Catch ex As Exception
            rgvWidth.CancelEdit()
            MsgBox(ex.Message, MsgBoxStyle.Exclamation, "Samtec Product Data Base")
            LoadMatedSetWidth()
        End Try
    End Sub


0
Jack
Telerik team
answered on 15 Jun 2010, 07:55 AM
Hi Jorge Mendoza Martinez,

Thank you for contacting us. I tested this case, however I was not able to reproduce the issue. Please send me your application and I will try to locate the issue and find a proper solution.  Thank you in advance.

I am looking forward to your reply.

Best wishes,
Jack
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
Tags
GridView
Asked by
Rehan
Top achievements
Rank 1
Answers by
Kiril
Telerik team
Rehan
Top achievements
Rank 1
David
Top achievements
Rank 1
Jack
Telerik team
ewart
Top achievements
Rank 1
Support
Top achievements
Rank 1
Ryan
Top achievements
Rank 1
Jorge Mendoza Martinez
Top achievements
Rank 1
Share this question
or