Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / ASP.NET / DataGrid / July 2004

Tip: Looking for answers? Try searching our database.

Dynamic Rows and Colors

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Randy Rubin - 26 Jul 2004 19:41 GMT
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.FieldValue("EngAdd
", Container)) Visible="False"/>') is not allowed within a
'System.Web.UI.WebControls.DataGridColumnCollection'.

So is there an easy way to do this?

Randy
Jared - 30 Jul 2004 14:46 GMT
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

> What I am trying to do is Change the color of a row from a value that is
> in
[quoted text clipped - 14 lines]
>
> Randy

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.