Perhaps the string is converted to a value that is out of the bounds of the Cell collection. Have you inspected Convert.ToInt32(str) in the watch window?
>I'm experieincing a weird situation on a custom control I've created from a DataGrid. What I was attempting to do is add a property in which I could specify a comma-delimted list of column indexes I want the control to automatically sum in the footer.
>
>To do this I've overriden the 'OnItemDataBound' event; for each row being bound, I get the value for each cell I've designated for summing. However, it seems that whenever I cast the cell value to a decimal (the type i need for summing) the control will not render in the designer. I get the following message:
>
>.. "There was an error rendering the control. Check to make sure all properties are valid".
>
>The only difference is how I'm referencing the index of the cell. If I use a variable, the rendering does not work:
>
>foreach(string str in summaryIndexes)
>{
> cellIndex = Convert.ToInt32(str);
> foreach(DataGridItem dgi in this.Items)
> {
> TableCell tc = dgi.Cells[cellIndex];
> }
>}
>
>... But it does work if I have a hard-coded interger instead:
>
>foreach(string str in summaryIndexes)
>{
> cellIndex = Convert.ToInt32(str);
> foreach(DataGridItem dgi in this.Items)
> {
> TableCell tc = dgi.Cells[0];
> }
>}
>
>Anyone know what the deal is?
Précédent
Suivant
Répondre
Voir le fil de ce thread
Voir le fil de ce thread à partir de ce message seulement
Voir tous les messages de ce thread
Voir tous les messages de ce thread à partir de ce message seulement