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

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

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.

4 Replies

AD Administrator Syncfusion Team 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.


PG Preethi Ghalke 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.


AD Administrator Syncfusion Team 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.


AD Administrator Syncfusion Team 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

Loader.
Live Chat Icon For mobile
Up arrow icon