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

Discussion in 'ASP .Net Web Controls' started by Dave, Jul 6, 2006.

  1. Dave

    Dave Guest

    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
     
    Dave, Jul 6, 2006
    #1
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. DP
    Replies:
    0
    Views:
    1,144
  2. Dave
    Replies:
    0
    Views:
    333
  3. pplnet
    Replies:
    2
    Views:
    2,636
    marina_yassa
    Mar 29, 2013
  4. Andries

    I know, I know, I don't know

    Andries, Apr 23, 2004, in forum: Perl Misc
    Replies:
    3
    Views:
    237
    Gregory Toomey
    Apr 23, 2004
  5. Tore Aursand

    Using $1, $2 ... but don't know in which order

    Tore Aursand, May 7, 2004, in forum: Perl Misc
    Replies:
    15
    Views:
    144
    Walter Roberson
    May 9, 2004
Loading...

Share This Page