![]() |
|
|
|||||||
![]() |
ASP Net - BGCOLOR of the row in dataGrid |
|
|
Thread Tools | Search this Thread |
|
|
#1 |
|
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 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 |
|
|
|
|
#2 |
|
Posts: n/a
|
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: > > <asp > 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 |
|
|
|
#3 |
|
Posts: 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" <> 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: > > > > <asp > > 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 |
|
|
|
#4 |
|
Posts: 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" <> 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: > > <asp > 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 |
|
![]() |
| Thread Tools | Search this Thread |
|
|
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 |