Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > BGCOLOR of the row in dataGrid

Reply
Thread Tools

BGCOLOR of the row in dataGrid

 
 
simon
Guest
Posts: n/a
 
      05-11-2004
I have dataGrid.
I would like that item background(row of the dataGrid) is red if the active
field in database is false
otherwise leave it like it is.

I tried like this:

<aspataGrid ItemStyle-BackColor='<%#
checkActive(DataBinder.Eval(Container.DataItem, "active"))%>'>

and in code behind:

Public Function checkActive(ByVal vrednost As Boolean) As Color
If vrednost = False Then
PreveriAktivnost = System.Drawing.Color.Red
End If
End Function

I get an error message:
'DataItem' is not a member of 'System.Web.UI.Control'.

How can I solve this problem? Maybe onItemCreated and check there?

Thank you,
Simon


 
Reply With Quote
 
 
 
 
Craig
Guest
Posts: n/a
 
      05-11-2004
Maybe the syntax is wrong? The syntax I use for framework 1.1 is.......
DataBinder.Eval(Container, "DataItem.ShortDesc")

"simon" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> I have dataGrid.
> I would like that item background(row of the dataGrid) is red if the

active
> field in database is false
> otherwise leave it like it is.
>
> I tried like this:
>
> <aspataGrid ItemStyle-BackColor='<%#
> checkActive(DataBinder.Eval(Container.DataItem, "active"))%>'>
>
> and in code behind:
>
> Public Function checkActive(ByVal vrednost As Boolean) As Color
> If vrednost = False Then
> PreveriAktivnost = System.Drawing.Color.Red
> End If
> End Function
>
> I get an error message:
> 'DataItem' is not a member of 'System.Web.UI.Control'.
>
> How can I solve this problem? Maybe onItemCreated and check there?
>
> Thank you,
> Simon
>
>



 
Reply With Quote
 
 
 
 
simon
Guest
Posts: n/a
 
      05-11-2004
no, the sintaks is ok.
I think I can't put the container in dataGrid tag.
I should use onItemcomand or something similar

thank you,
Simon

"Craig" <(E-Mail Removed)> wrote in message
news:%(E-Mail Removed)...
> Maybe the syntax is wrong? The syntax I use for framework 1.1 is.......
> DataBinder.Eval(Container, "DataItem.ShortDesc")
>
> "simon" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
> > I have dataGrid.
> > I would like that item background(row of the dataGrid) is red if the

> active
> > field in database is false
> > otherwise leave it like it is.
> >
> > I tried like this:
> >
> > <aspataGrid ItemStyle-BackColor='<%#
> > checkActive(DataBinder.Eval(Container.DataItem, "active"))%>'>
> >
> > and in code behind:
> >
> > Public Function checkActive(ByVal vrednost As Boolean) As Color
> > If vrednost = False Then
> > PreveriAktivnost = System.Drawing.Color.Red
> > End If
> > End Function
> >
> > I get an error message:
> > 'DataItem' is not a member of 'System.Web.UI.Control'.
> >
> > How can I solve this problem? Maybe onItemCreated and check there?
> >
> > Thank you,
> > Simon
> >
> >

>
>



 
Reply With Quote
 
Eliyahu Goldin
Guest
Posts: n/a
 
      05-11-2004
You can use ItemDataBound event like this:

private void yourDataGrid_ItemDataBound (object sender,
System.Web.UI.WebControls.DataGridItemEventArgs e)
{
if ((e.Item.ItemType == ListItemType.Item) ||
(e.Item.ItemType == ListItemType.AlternatingItem))
if (e.Item.Cells["active"].Text == "Y")
e.Item.BackColor = System.Drawing.Color.Red;
}

Eliyahu

"simon" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> I have dataGrid.
> I would like that item background(row of the dataGrid) is red if the

active
> field in database is false
> otherwise leave it like it is.
>
> I tried like this:
>
> <aspataGrid ItemStyle-BackColor='<%#
> checkActive(DataBinder.Eval(Container.DataItem, "active"))%>'>
>
> and in code behind:
>
> Public Function checkActive(ByVal vrednost As Boolean) As Color
> If vrednost = False Then
> PreveriAktivnost = System.Drawing.Color.Red
> End If
> End Function
>
> I get an error message:
> 'DataItem' is not a member of 'System.Web.UI.Control'.
>
> How can I solve this problem? Maybe onItemCreated and check there?
>
> Thank you,
> Simon
>
>



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
bgcolor of repeater row simon ASP .Net 3 05-31-2005 12:57 PM
How to chang bgcolor of row when mouse selected a row? Charles Shao ASP .Net 1 04-18-2005 11:11 AM
Set bgcolor of a newly added table row? Martin Javascript 2 11-19-2004 06:45 PM
Changing DataGrid Item BGCOLOR =?Utf-8?B?SkM=?= ASP .Net 1 03-06-2004 02:26 AM
Can not seem to alter table row bgcolor using DOM TC Javascript 0 02-24-2004 09:57 PM



Advertisments