Professional Web Applications Themes

Dynamic Rows and Colors - ASP.NET Data Grid Control

What I am trying to do is Change the color of a row from a value that is in a Database using the ItemStyle-BackColor Property. The value in the DB is the color name. I keep getting a number of errors: BC30676: 'DataBinding' is not an event of 'System.Web.UI.WebControls.BoundColumn' Or Literal content ('<asp:BoundColumn DataField="UID" HeaderText="UID" ItemStyle-Font-Size="8" ReadOnly="true" ItemStyle-BackColor=system.drawing.color.fromname(BomView.Fi eldValue("EngAdd ", Container)) Visible="False"/>') is not allowed within a 'System.Web.UI.WebControls.DataGridColumnCollectio n'. So is there an easy way to do this? Randy...

  1. #1

    Default Dynamic Rows and Colors

    What I am trying to do is Change the color of a row from a value that is in
    a Database using the ItemStyle-BackColor Property. The value in the DB is
    the color name. I keep getting a number of errors:

    BC30676: 'DataBinding' is not an event of
    'System.Web.UI.WebControls.BoundColumn'

    Or
    Literal content ('<asp:BoundColumn DataField="UID" HeaderText="UID"
    ItemStyle-Font-Size="8" ReadOnly="true"
    ItemStyle-BackColor=system.drawing.color.fromname(BomView.Fi eldValue("EngAdd
    ", Container)) Visible="False"/>') is not allowed within a
    'System.Web.UI.WebControls.DataGridColumnCollectio n'.


    So is there an easy way to do this?

    Randy


    Randy Rubin Guest

  2. #2

    Default Re: Dynamic Rows and Colors

    Randy,
    Something like this should work for you.
    Jared

    Private Sub DataGrid1_ItemDataBound(ByVal sender As Object, ByVal e As
    System.Web.UI.WebControls.DataGridItemEventArgs) Handles
    DataGrid1.ItemDataBound
    If Not e.Item.DataItem Is Nothing Then
    If e.Item.ItemType = ListItemType.AlternatingItem Or
    ListItemType.Item Or ListItemType.SelectedItem Then
    Dim Item As DataGridItem = CType(e.Item, DataGridItem)
    Item.BackColor =
    Color.FromName(DataBinder.GetPropertyValue(e.Item. DataItem,
    "FieldContainingColorName"))
    End If
    End If
    End Sub


    "Randy Rubin" <randyimarubin.com> wrote in message
    news:Of5df$zcEHA.596TK2MSFTNGP11.phx.gbl...
    > What I am trying to do is Change the color of a row from a value that is
    > in
    > a Database using the ItemStyle-BackColor Property. The value in the DB is
    > the color name. I keep getting a number of errors:
    >
    > BC30676: 'DataBinding' is not an event of
    > 'System.Web.UI.WebControls.BoundColumn'
    >
    > Or
    > Literal content ('<asp:BoundColumn DataField="UID" HeaderText="UID"
    > ItemStyle-Font-Size="8" ReadOnly="true"
    > ItemStyle-BackColor=system.drawing.color.fromname(BomView.Fi eldValue("EngAdd
    > ", Container)) Visible="False"/>') is not allowed within a
    > 'System.Web.UI.WebControls.DataGridColumnCollectio n'.
    >
    >
    > So is there an easy way to do this?
    >
    > Randy
    >
    >

    Jared Guest

Similar Threads

  1. Question Insert multiple rows with dynamic data
    By gassmann56560 in forum Coldfusion - Getting Started
    Replies: 0
    Last Post: April 6th, 07:02 PM
  2. Data Grid Dynamic Cell Colors
    By rockstarkate78 in forum Macromedia Flash Data Integration
    Replies: 0
    Last Post: March 14th, 08:26 PM
  3. datagrid rows colors in Flex
    By ezd_macromedia in forum Macromedia Flex General Discussion
    Replies: 12
    Last Post: August 31st, 07:26 PM
  4. Dynamic table rows
    By Dan Joyce in forum Macromedia Dynamic HTML
    Replies: 20
    Last Post: May 10th, 11:16 PM
  5. Selecting colors in dynamic datagrid
    By et in forum ASP.NET Data Grid Control
    Replies: 1
    Last Post: December 28th, 03:37 AM

Bookmarks

Posting Permissions

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

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139