dcsimg
www.webdeveloper.com
Results 1 to 3 of 3

Thread: Item databound

  1. #1
    Join Date
    Jan 2005
    Posts
    209

    Question Item databound

    I need a row to change colour if the value in a certain column in the database is true.

    EG If the column "completed" in the database has a value of 'true' for a certain row then I'd like that row in the datagrid to be blue.

    I have this:
    If e.Item.ItemType = ListItemType.Item Or _
    e.Item.ItemType = ListItemType.AlternatingItem Then

    If e.Item.DataItem("Actioned") = "0" Then _
    e.Item.BackColor = System.Drawing.Color.FromName("#ff6")

    Which works but I need to add to it so that the value of "completed" is looked up in the database rather than the datagrid like above.

    Thanks

  2. #2
    Join Date
    Oct 2004
    Posts
    34
    Add a label with the primary key of your table to the datagrid (make it invisible), find the row according to the label's value, and set the datagrid's row color accordingly.

  3. #3
    Join Date
    Jan 2005
    Posts
    209

    Talking Update for anyone with the same question

    If e.Row.RowType = DataControlRowType.DataRow Then
    'Determine the value of the Actioned field and colour accordingly
    Dim Actioned As String = (DataBinder.Eval(e.Row.DataItem, "Actioned"))
    If Actioned = "False" Then
    ' Color the background of the row yellow
    e.Row.BackColor = System.Drawing.Color.FromName("#D7E3F4")
    ElseIf Actioned = "True" Then
    ' Color the background of the row yellow
    e.Row.BackColor = System.Drawing.Color.FromName("#EFF3FB")
    End If
    End If

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles