Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
343
Index was outside the bounds of the array.
posted

Hi All,

i have 2 xamdatagrid and i want transfer the data from one to another one 

the sender xamdatagrid "xampaxCost" has about 5 record instead the receiver"xamPaxCost_Copy" has 0 record (empty),

both are set up in this way in xaml

<Custom:XamDataGrid.FieldLayoutSettings>
<Custom:FieldLayoutSettings HighlightAlternateRecords="True" AllowAddNew="True" AutoGenerateFields="False" />
</Custom:XamDataGrid.FieldLayoutSettings>
<igDP:XamDataGrid.FieldSettings>

<igDP:FieldSettings AllowEdit="true"/>

</igDP:XamDataGrid.FieldSettings>
<Custom:XamDataGrid.FieldLayouts>
<Custom:FieldLayout>
<Custom:Field Name="Name" Label="Pax Label" Width="77">

</Custom:Field>
<Custom:CurrencyField Mask="nnnnnnnnnn.n" Name="Price" Width="70" Label="Pax Price" />
<Custom:Field Name="CODE" Width="70" Label="CODE" />
</Custom:FieldLayout>
</Custom:XamDataGrid.FieldLayouts>

and there  is a button to transfer the data with the code behind so:

for (int i = 0; i < xamPaxCost.Records.Count; i++)
{

(xamPaxCost_Copy.Records[i -1] as DataRecord).Cells[0].Value = (xamPaxCost.Records[i] as DataRecord).Cells[0].Value.ToString();// ERROR
(xamPaxCost_Copy.Records[i] as DataRecord).Cells[1].Value = (xamPaxCost.Records[i] as DataRecord).Cells[1].Value.ToString();
(xamPaxCost_Copy.Records[i] as DataRecord).Cells[2].Value = result.ToString();

}

in the first line i got the error " Index was outside the bounds of the array."

Do you have any idea how to work out this error.

Thanks

Best Regards

Parents
No Data
Reply
  • 16495
    Offline posted

     

    Hello,

     

    Thank you for your post.

     

    I have been looking into the code snippet you have provided. The behavior  you have described is expected, because in the first line you are trying to set the Record with index ‘[-1]’ . You can avoid this error if insert the correct index. I suppose it should be just 'i'.  I created short sample application based on your scenario in order to show you how you can achieve the functionality you are looking fom .

    Please let me know if I am missing something from your scenario and feel free to modify the sample application if it does not cover your expectations.

     

    Please let me know if you require any further assistance on the matter.

    TransferData.zip
Children