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
close icon

Get Selected Rows GDBG

After performing a control-click to select multiple rows, how can I retrieve the corresponding DataRow's for a GridDataboundGrid? Version 5.2

thx

2 Replies

AD Administrator Syncfusion Team October 1, 2007 03:38 PM UTC

Here is code in a button click handler that I think does what you requested.


private void button1_Click(object sender, EventArgs e)
{
GridRangeInfoList rangeList = gridDataBoundGrid1.Selections.GetSelectedRows(true, false);

CurrencyManager cm = gridDataBoundGrid1.BindingContext[gridDataBoundGrid1.DataSource, gridDataBoundGrid1.DataMember] as CurrencyManager;

if (cm != null)
{
DataView dv = cm.List as DataView;
if (dv != null)
{
foreach (GridRangeInfo range in rangeList)
{
for (int row = range.Top; row <= range.Bottom; ++row)
{
DataRow dr = dv[gridDataBoundGrid1.Binder.RowIndexToPosition(row)].Row;
Console.WriteLine(dr[0]);
}
}
}
}
}



JS John Slater October 1, 2007 04:04 PM UTC

Thanks Clay,

As always, it works perfectly.

>Here is code in a button click handler that I think does what you requested.


private void button1_Click(object sender, EventArgs e)
{
GridRangeInfoList rangeList = gridDataBoundGrid1.Selections.GetSelectedRows(true, false);

CurrencyManager cm = gridDataBoundGrid1.BindingContext[gridDataBoundGrid1.DataSource, gridDataBoundGrid1.DataMember] as CurrencyManager;

if (cm != null)
{
DataView dv = cm.List as DataView;
if (dv != null)
{
foreach (GridRangeInfo range in rangeList)
{
for (int row = range.Top; row <= range.Bottom; ++row)
{
DataRow dr = dv[gridDataBoundGrid1.Binder.RowIndexToPosition(row)].Row;
Console.WriteLine(dr[0]);
}
}
}
}
}



Loader.
Live Chat Icon For mobile
Up arrow icon