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

SelectedRecord changed returns wrong value

Thread ID:

Created:

Updated:

Platform:

Replies:

88804 Aug 12,2009 01:58 PM UTC Sep 5,2009 06:35 AM UTC Windows Forms 5
loading
Tags: GridControl
Santosh U
Asked On August 12, 2009 01:58 PM UTC

Hi,

I have a GGC which has List of the Products. On selecting particular product from the grid I am populating its details and showing it in a edit form. I am facing a problem giving different record then what is expected.
Here is my code below.

private void gridGroupingControl1_SelectedRecordsChanged(object sender, SelectedRecordsChangedEventArgs e)
{
try
{
if (e.SelectedRecord != null && e.SelectedRecord.Record.Kind != DisplayElementKind.AddNewRecord)
{
//int productid = Convert.ToInt32(e.SelectedRecord.Record.GetValue("PRODUCT_ID").ToString());
int productid = Convert.ToInt32(gridGroupingControl1.Table.CurrentRecord.GetValue("PRODUCT_ID").ToString());
LoadProductDetails(productid);
}
}
catch (OverflowException oex)
{
}
}

When I debug first of all this gets called twice (I agree since one record gets defocused and another gets it).
But finally when it returns me the product ID it returns me the previous records id.
This happens when I instead of clicking and selecting the record I use UP and DOWN key of the keyboard. One more thing I have noticed that it returns different record for e.SelectedRecord and ggc.Table.CurrentRecord. One more weired thing is that this happens when I use UP key rather than DOWN Key.

Please let me know if I am doing anything wrong or there is something else.

Thanks,
Santosh U

Jisha Joy [Syncfusion]
Replied On August 13, 2009 09:14 AM UTC

Hi Santhosh,

In GridGroupingControl,you could get the selected records by just looping through the Table.SelectedRecords collection. See the code:

// For GridGroupingControl

foreach(SelectedRecord rec in this.gridGroupingControl1.Table.SelectedRecords)
Console.WriteLine(rec.Record.ToString());

Please let me know if this helps.

Regards,
Jisha

Joshua
Replied On August 14, 2009 01:51 PM UTC

If it is a single select grid then try
Datarow gridRow = ((DataRowView)gridcontrol.Table.SelectedRecords[0].Record.GetData()).Row;
if(null !- gridrow)
{
int productid = (int)gridrow["productid"];
}

Santosh U
Replied On August 18, 2009 02:35 PM UTC

Hi,

I have tried this on GGC but this throws and Index out of range exception. But when i check SelectedRecord it shows me the values.

The issue of showing wrong selected record still persists, Please help.

Thanks,
Santosh U

Santosh U
Replied On August 26, 2009 01:11 PM UTC

Hi,

Any updates on this please, This is still not having any solution. I tried many work-arounds.

Thanks,
Santosh U

Santosh U
Replied On September 5, 2009 06:35 AM UTC

Hi Jisha,

I simply added this if statement and got the solution.

if (e.Action == SelectedRecordsChangedType.Added)

Thanks,
Piyush

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

;