We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

DataRow of a DataGrid Cell

Is there a way of getting a reference to the DataRow in the Underlying DataTable of the selected DataGrid Cell. I was using the Row Number of the Cell, but when a row is deleted the Row Numbers do not match up. Any ideas??? Matt

4 Replies

MW Matthew Williams February 17, 2003 06:42 AM UTC

Please HELP I really need to know how to do this!!!!! Matt


JI jim February 19, 2003 10:16 PM UTC

look in the faq 5.67 and 5.29 might help.


MW Matthew Williams March 5, 2003 06:47 AM UTC

> look in the faq 5.67 and 5.29 might help. I thought that faq 5.67 would help but it still references the deleted record I'll give you a little background in what I am trying to do. I have a table containing VAT Codes and their vat rates: |VAT Code|VAT Rate| |--------|--------| |A | 0.5| |B | 0.6| |C | 0.7| I need to know what rows were added, deleted or edited. So I have called the: Me.dtVATCodes.AcceptChanges() method. As this only marks rows for deletion so that I can track the changes. The problem I am having is when I Delete the second row (B) and I use the method in faq 5.67: With objDG Dim bm As BindingManagerBase = .BindingContext(.DataSource, .DataMember) Return CType(bm.Current, DataRowView).Row End With when on the new second Row (C) I am referencing the deleted row. Am I doing something very silly or is there another way of doing this?? Thanks. Matt PS. I really need to get this done yesterday


SA Sameer April 23, 2003 01:23 PM UTC

I am giving it a shot, i dont know if this is REALLY ur problem, DataView currentView ; currentView = new DataView( [ur table from the DataSet goes here]) ; DataGrid dg = new DataGrid() ; dg.Source = currentView ; and then .... wherever u need to know ur row int index = dg.CurrentRowIndex ; DataRow dr ; DataRowView drv = currentView[index] ; dr = drv.Row; I hope this helps. -S > > look in the faq 5.67 and 5.29 might help. > > > I thought that faq 5.67 would help but it still references the deleted record > > I'll give you a little background in what I am trying to do. > > I have a table containing VAT Codes and their vat rates: > > |VAT Code|VAT Rate| > |--------|--------| > |A | 0.5| > |B | 0.6| > |C | 0.7| > > I need to know what rows were added, deleted or edited. So I have called the: > > Me.dtVATCodes.AcceptChanges() > > method. As this only marks rows for deletion so that I can track the changes. > > The problem I am having is when I Delete the second row (B) and I use the method in faq 5.67: > > With objDG > Dim bm As BindingManagerBase = .BindingContext(.DataSource, .DataMember) > Return CType(bm.Current, DataRowView).Row > End With > > when on the new second Row (C) I am referencing the deleted row. Am I doing something very silly or is there another way of doing this?? > > > Thanks. > > Matt > > PS. I really need to get this done yesterday

Loader.
Live Chat Icon For mobile
Up arrow icon