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

Button cell in databound grid

I am using a button cell in a databound grid to select a record using the event "PushButtonClick" The code I am using works fine when the grid is loaded, however when sorting using one of the headers and clicking the button it retrieves the wrong record. Code is below gdbgGrid.CurrentCell.MoveTo(e.RowIndex, e.ColIndex); dt = (DataTable)gdbgGrid.DataSource; DNoteID = (Guid)dt.Rows[e.RowIndex-1]["DNoteID"]; How can I get the correct index from the grid when it is sorted. Thanks Aaron

1 Reply

AD Administrator Syncfusion Team March 31, 2005 09:10 AM

You need to use the CurrencyManager to access the data if it can possibly be sorted. int pos = grid.Binder.RowIndexToPosition(e.RowIndex); CurrencyManager cm = (CurrencyManager) grid.BindingContext[grid.DataSource, grid.DataMember]; DataRowView drv = (DataRowView)cm.List[pos]; //DataRow dr = drv.Row; MessageBox.Show(string.Format("{0} {1}", drv["1"], drv["2"]));

Loader.
Live Chat Icon For mobile
Up arrow icon