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. (Last updated on : Nov 16th 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Button cell in databound grid

Thread ID:

Created:

Updated:

Platform:

Replies:

26783 Mar 31,2005 02:05 PM UTC Mar 31,2005 02:10 PM UTC WinForms 1
loading
Tags: GridControl
Administrator [Syncfusion]
Asked On March 31, 2005 02:05 PM UTC

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

Administrator [Syncfusion]
Replied On March 31, 2005 02:10 PM UTC

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"]));

CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

;