Even more fun with @%&$@$%# Datagrids!
Visual Basic
1
Posts
1
Posters
0
Views
1
Watching
-
I have one last line of code to write then this project is complete. I have spent 2 weeks on this "Last Line" .... :-) Trying to read the contents of a datagrid to Excel: This works if the column is simply a bound column: For i = 0 To StatusGrid.Items.Count - 1 worksheet.Cells(i + 2, 1) = StatusGrid.Items(i).Cells(1).Text() Next However, for Template columns, the following SHOULD work, but does not: For i = 0 To StatusGrid.Items.Count - 1 worksheet.Cells(i + 2, 2) = CType(StatusGrid.Items(i).Cells(2).Controls(0), DataBoundLiteralControl).Text() Next I get the following error: Unable to cast object of type 'System.Web.UI.LiteralControl' to type 'System.Web.UI.DataBoundLiteralControl'. I am at my wit's end on this one... Can anyone help?