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.
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

How to get DataRow object of a selected row in the Grid

Thread ID:

Created:

Updated:

Platform:

Replies:

39718 Jan 17,2006 09:15 AM UTC Feb 7,2006 03:04 PM UTC Windows Forms 4
loading
Tags: GridControl
Preethi Ghalke
Asked On January 17, 2006 09:15 AM UTC

Hi All, I have a private method which populates the Grid with the DataRow objects. Now I want to get hold of the underlying DataRow object of the selected row. I tried doing the following but it fails: private void singleColumnPKGrid__SelectionChanged(object sender, GridSelectionChangedEventArgs e) { this.mbPKStatus_.Enabled = true; this.mbViewPKProp_.Enabled = true; CurrencyManager cm = grid.BindingContext[grid.DataSource, grid.DataMember] as CurrencyManager; int i = cm.Count; //this returns an interger value DataRow dr = ((DataRowView)cm.Current).Row; // this fails. String str = dr[RID_COLNAME].ToString(); } Is this the right way ? if no, can anybody help us with an appropriate code sample. A quick response will be appreciated as I''m unable to proceed. Thanks in advance. Best Regards, Preethi.

Administrator [Syncfusion]
Replied On January 17, 2006 12:26 PM UTC

Hi Preethi, Attached is a sample which gets a column value from the underlying DataRow. If you can reproduce the issue in the attached sample and send it back, we can get back soon with a solution. Regards, Calvin.

Preethi Ghalke
Replied On January 19, 2006 07:49 AM UTC

Hi Calvin, Thanks for your prompt response. Will checkout the sample n let you know if we are doing any different in our code. Regards, Preethi. >Hi Preethi, > >Attached is a sample which gets a column value from the underlying DataRow. If you can reproduce the issue in the attached sample and send it back, we can get back soon with a solution. > >Regards, >Calvin.

Administrator [Syncfusion]
Replied On February 7, 2006 03:01 PM UTC

Hello, I found that the "official example" from the Knowledge Base isn''t working for me. I never get the right row when I use: CurrencyManager cm = (CurrencyManager)this.BindingContext[this.gridDataBoundGrid1.DataSource]; DataRowView dr = (DataRowView)cm.Current; as described in the example. What is working for me is: CurrencyManager cm = (CurrencyManager) this.BindingContext[this.grid1.DataSource, this.grid1.DataMember]; DataRow dr = ((DataRowView) ((DataView)cm.List)[grid1.Binder.CurrentPosition]).Row; I can''t say that I understand what happens here. Do I make something wrong? The underlying Datasource for the GDBG is a DataTable and I''m working with Syncfusion 4.1 and VSProf2003 (.NET 1.1). >Hi Calvin, > >Thanks for your prompt response. > >Will checkout the sample n let you know if we are doing any different in our code. > >Regards, >Preethi. > >>Hi Preethi, >> >>Attached is a sample which gets a column value from the underlying DataRow. If you can reproduce the issue in the attached sample and send it back, we can get back soon with a solution. >> >>Regards, >>Calvin.

Administrator [Syncfusion]
Replied On February 7, 2006 03:04 PM UTC

Sorry, I''ve made a mistake in my preious posting: What is NOT working from the Knowledeg Base is: CurrencyManager cm = (CurrencyManager) this.BindingContext[this.gridDataBoundGrid1.DataSource, this.gridDataBoundGrid1.DataMember]; DataRow dr = ((DataRowView) cm.Current).Row; Hope I got it now. Regards Volker

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

;