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

Index Error

Thread ID:

Created:

Updated:

Platform:

Replies:

54610 Jan 12,2007 10:54 AM UTC Jan 12,2007 12:06 PM UTC Windows Forms 4
loading
Tags: GridControl
leemarose
Asked On January 12, 2007 10:54 AM UTC

Hi All!

I have a set of record in my griddataboundgrid
When i delete any record in the gridits show Error
message like..

"Index was out of range. Must be non-negative and less than the size of the collection.Parameter name: index"

When i trace through my code it catch error in
grid.CommitChanges line.

Can u suggest me the solution please..

Regards

Leema



Administrator [Syncfusion]
Replied On January 12, 2007 11:17 AM UTC

Hi Leema,

I think the record you are trying to delete is not there in the underlying datasource. Please try this code to delete the record from grid.

int rowIndex = 1;
if( this.gridDataBoundGrid1.Model.RowCount -1 > rowIndex )
this.gridDataBoundGrid1.DeleteRecordsAtRowIndex(rowIndex,rowIndex);

Best Regards,
Haneef

Administrator [Syncfusion]
Replied On January 12, 2007 11:30 AM UTC

Hi,
Error is coming in "PrepareViewStyleInfo", When i delete.

In "PrepareViewStyleInfo" i have written like this. My grid display is in multiline view [1 datarow equal 2 lines in grid ]
CurrencyManager cm = (CurrencyManager)this.BindingContext[this.DataSource];
CLIBidSheet aBidSheet = (CLIBidSheet)(cm.List);
CLIBidItem dr = (CLIBidItem)aBidSheet[((e.RowIndex-2) / 2)];

can you suggest me a solution.

Administrator [Syncfusion]
Replied On January 12, 2007 11:47 AM UTC

Hi Leema,

Could you please use this code snippet to access the CLIBidItem from CLIBidSheet in a PrepareViewStyleInfo event.

CurrencyManager cm = (CurrencyManager)this.BindingContext[this.DataSource];
CLIBidSheet aBidSheet = (CLIBidSheet)(cm.List);

int index = (int)((e.RowIndex-2) / 2);
if( index >= 0 && index < cm.List.Count)
{
CLIBidItem dr = (CLIBidItem)aBidSheet[index];
//Your related code here
}

Let me know if this helps.

Best Regards,
Haneef

Administrator [Syncfusion]
Replied On January 12, 2007 12:06 PM UTC

Thanks,
Its working.

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

;