T
Tina
I have a DataGrid Item from the header row of a 1.1 DataGrid. I got it by
saying...
Dim HeaderItem As DataGridItem = mygrid.Controls(0).Controls(0)
Now I'm looping through the Header item cells but first testing each cell as
so....
If HeaderItem.Cells(i).Controls(0) Is Nothing Then ...
the reason for this test is that sometimes the heading text is in
HeaderItem.Cells(i).text (in the case of a normal heading) and sometimes
it's inside a LinkButton (in the case of a sort enabled column).
My problem is that this "is Nothing" test throws an exception if the cell
being tested has no Controls collection. So testing for Is Nothing doesn't
work because the test gets an index out of bounds exception.
How can I test for the lack of the controls collection without getting an
exception.
(I don't want to put this into a try-catch block for performance reasons)
(also please understand that I am in a method that is getting passed this
datagrid - not in any event while it is being built)
Thanks,
T
saying...
Dim HeaderItem As DataGridItem = mygrid.Controls(0).Controls(0)
Now I'm looping through the Header item cells but first testing each cell as
so....
If HeaderItem.Cells(i).Controls(0) Is Nothing Then ...
the reason for this test is that sometimes the heading text is in
HeaderItem.Cells(i).text (in the case of a normal heading) and sometimes
it's inside a LinkButton (in the case of a sort enabled column).
My problem is that this "is Nothing" test throws an exception if the cell
being tested has no Controls collection. So testing for Is Nothing doesn't
work because the test gets an index out of bounds exception.
How can I test for the lack of the controls collection without getting an
exception.
(I don't want to put this into a try-catch block for performance reasons)
(also please understand that I am in a method that is getting passed this
datagrid - not in any event while it is being built)
Thanks,
T