By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,191 Members | 1,411 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,191 IT Pros & Developers. It's quick & easy.

BGCOLOR of the row in dataGrid

P: n/a
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:

<asp:DataGrid 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
Nov 18 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
Maybe the syntax is wrong? The syntax I use for framework 1.1 is.......
DataBinder.Eval(Container, "DataItem.ShortDesc")

"simon" <si*********@stud-moderna.si> wrote in message
news:ud**************@TK2MSFTNGP10.phx.gbl...
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:

<asp:DataGrid 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

Nov 18 '05 #2

P: n/a
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" <no****@austin.rr.com> wrote in message
news:%2****************@TK2MSFTNGP09.phx.gbl...
Maybe the syntax is wrong? The syntax I use for framework 1.1 is.......
DataBinder.Eval(Container, "DataItem.ShortDesc")

"simon" <si*********@stud-moderna.si> wrote in message
news:ud**************@TK2MSFTNGP10.phx.gbl...
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:

<asp:DataGrid 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


Nov 18 '05 #3

P: n/a
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" <si*********@stud-moderna.si> wrote in message
news:ud**************@TK2MSFTNGP10.phx.gbl...
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:

<asp:DataGrid 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

Nov 18 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.