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
JJ
Jisha Joy
Syncfusion Team
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
JO
Joshua
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"];
}
SU
Santosh U
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
SU
Santosh U
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
SU
Santosh U
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