don't know which kind of object to select in a gridview

D

Dave

Hi,

I want to change the color of two fields (a checkbox and a 'normal
stringfield') of my gridview depending of their value. The checkbox works
with the code below.
My question is: what do i have to take as object for the 'normal
stringfield'? I tried with 'textbox', with 'label' ... but each time i get
the error:
"Specified argument was out of the range of valid values. Parameter name:
index"

Protected Sub GridView1_RowDataBound(ByVal sender As Object, ByVal e As
System.Web.UI.WebControls.GridViewRowEventArgs) Handles
GridView1.RowDataBound
Dim cb As New CheckBox
Dim a As ???
cb = e.Row.Cells(6).Controls(0)
a = e.Row.Cells(5).Controls(0)
If cb.Checked Then
e.Row.Cells(0).BackColor = Drawing.Color.Red
e.Row.Cells(6).BackColor = Drawing.Color.Red
End If

if a.text (or matbe a.value) = "fat" then
e.Row.Cells(6).BackColor = Drawing.Color.Green
End If
End Sub

Thanks
Dave
 

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,012
Latest member
RoxanneDzm

Latest Threads

Top