gridview rowdatabound cell index bug?

T

tfsmag

I'm having a weird problem with the rowdatabound event for a gridview
in my application... Here is the code.
--------------------------------------
Protected Sub AnswersGrid_RowDataBound(ByVal sender As Object, ByVal e
As System.Web.UI.WebControls.GridViewRowEventArgs) Handles
AnswersGrid.RowDataBound
If e.Row.Cells(1).Text = "True" Or e.Row.Cells.Item(1).Text =
"False" Then
Dim editbutton As LinkButton =
e.Row.FindControl("LinkButton1")
editbutton.Visible = False
End If
If e.Row.Cells(0).Text = "Y" Then
e.Row.Cells(1).BackColor = Drawing.Color.LightGray
End If
e.Row.Cells(0).Visible = False
End Sub
-----------------------------------
The problem is that the gridview has 4 cells, and if i print out the
e.row.cells.count it comes up as 4. However, when I try to see if the
text in cell(1) is "true" or "false" it tells me that the index is out
of range. I know that it is not out of range because it let's me set
the background color of cell(1) at the bottom of the code. Any ideas
what's going on or how to resolve it?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,014
Latest member
BiancaFix3

Latest Threads

Top