Go Back   Velocity Reviews > Newsgroups > ASP Net
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

Reply

ASP Net - BGCOLOR of the row in dataGrid

 
Thread Tools Search this Thread
Old 05-11-2004, 12:41 PM   #1
Default BGCOLOR of the row in dataGrid


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




simon
  Reply With Quote
Old 05-11-2004, 01:04 PM   #2
Craig
 
Posts: n/a
Default Re: BGCOLOR of the row in dataGrid
Maybe the syntax is wrong? The syntax I use for framework 1.1 is.......
DataBinder.Eval(Container, "DataItem.ShortDesc")

"simon" <> wrote in message
news:...
> 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
>
>





Craig
  Reply With Quote
Old 05-11-2004, 01:36 PM   #3
simon
 
Posts: n/a
Default Re: BGCOLOR of the row in dataGrid
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" <> wrote in message
news:%...
> Maybe the syntax is wrong? The syntax I use for framework 1.1 is.......
> DataBinder.Eval(Container, "DataItem.ShortDesc")
>
> "simon" <> wrote in message
> news:...
> > 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
> >
> >

>
>





simon
  Reply With Quote
Old 05-11-2004, 02:55 PM   #4
Eliyahu Goldin
 
Posts: n/a
Default Re: BGCOLOR of the row in dataGrid
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" <> wrote in message
news:...
> 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
>
>





Eliyahu Goldin
  Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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

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

Similar Threads
Thread Thread Starter Forum Replies Last Post
Get datagrid textbox value kanchangorak Software 0 03-11-2009 11:11 AM
Loading 24,000 rows into C# .net Datagrid Kagu Software 0 03-10-2009 06:51 PM
validating textbox inside datagrid susan_1516 Software 0 11-09-2008 01:29 PM
ASP.NET VB Using ItemDataBound to create textbox in datagrid rows. smi59550 General Help Related Topics 0 01-18-2008 07:42 PM
Disable ASP Button in a Datagrid ChrisClayko General Help Related Topics 0 08-02-2006 03:08 AM




SEO by vBSEO 3.3.2 ©2009, Crawlability, Inc.

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