Ask a Question related to ASP.NET Data Grid Control, Design and Development.
-
QUASAR #1
Change style of a single row of the item list of datagrid, based on a field value of current item...
Sorry for the long subject guys, but I don't know how better I can resume
the matter...
Anyway, I have my datagrid showing items of an order.
I want to have different backcolor of the rows based on the value of the
ItemType field of the current item (datagrid row)...
Example, if the current item (datagrid row) ItemType filed value is 1 i
wanna have this row backcolor red, if 2 then yellow, and so on...
Was very clear how to do this in classic asp but now using the datagrid
control nomore...
I know I can use a datalist that is more flexible, but I wanna use datagrid
:)
Thanks! ;)
QUASAR Guest
-
Cannot change datagrid item background colourdynamically
Hello, I am trying to change the background colour of a data grid item dynamically. I am using a component for each item with the item_renderer... -
datagrid checkbox list edit item not working
I am using asp template columns. I display box values from a lookup table. The datagrid displays field "bookid" and the checkbox displays... -
Single item Array Problem
Hi, I have a XML file like this: ... <pdpCategory name="Acute Illness"> <pdpMeasure name = "First Line Antibiotics">... -
How to set selected item in drop-down list in datagrid
Donald Welker wrote: SelectedValue='<%# DataBinder.Eval(Container.DataItem,"ABCField") %>' -- Jos -
Add single item to number of files in one step
Several FAX/DOCUMENT managing programs make multi-page TIFFs. Even the Windows Imaging proggie that shipped with Windows 9x does. Mac -
Alvin Bruney #2
Re: Change style of a single row of the item list of datagrid, based on a field value of current item...
trap the itemdatabound event
if(e.item.listitemtype == listitemtype.item or alternateitem)
e.item.cells[0].BackColor = System.Drawing.Color.Red;
roughly
--
Regards,
Alvin Bruney
Got tidbits? Get it here...
[url]http://tinyurl.com/3he3b[/url]
"QUASAR" <gz77@tiscali.it> wrote in message
news:OVgy5Gu2DHA.2548@tk2msftngp13.phx.gbl...datagrid> Sorry for the long subject guys, but I don't know how better I can resume
> the matter...
>
> Anyway, I have my datagrid showing items of an order.
> I want to have different backcolor of the rows based on the value of the
> ItemType field of the current item (datagrid row)...
> Example, if the current item (datagrid row) ItemType filed value is 1 i
> wanna have this row backcolor red, if 2 then yellow, and so on...
> Was very clear how to do this in classic asp but now using the datagrid
> control nomore...
> I know I can use a datalist that is more flexible, but I wanna use> :)
>
> Thanks! ;)
>
>
Alvin Bruney Guest
-
QUASAR #3
Re: Change style of a single row of the item list of datagrid, based on a field value of current item...
Alvin thanks a lot.
I suppose the code given is C wich is not familiar to me (i'm a really newby
:) )
Can you detail a bit more in VB ?
Thanks,
Quasar ;)
"Alvin Bruney" <vapor at steaming post office> ha scritto nel messaggio
news:uR3$KKu2DHA.3140@tk2msftngp13.phx.gbl...resume> trap the itemdatabound event
> if(e.item.listitemtype == listitemtype.item or alternateitem)
> e.item.cells[0].BackColor = System.Drawing.Color.Red;
>
> roughly
>
> --
> Regards,
> Alvin Bruney
> Got tidbits? Get it here...
> [url]http://tinyurl.com/3he3b[/url]
> "QUASAR" <gz77@tiscali.it> wrote in message
> news:OVgy5Gu2DHA.2548@tk2msftngp13.phx.gbl...> > Sorry for the long subject guys, but I don't know how better I can> datagrid> > the matter...
> >
> > Anyway, I have my datagrid showing items of an order.
> > I want to have different backcolor of the rows based on the value of the
> > ItemType field of the current item (datagrid row)...
> > Example, if the current item (datagrid row) ItemType filed value is 1 i
> > wanna have this row backcolor red, if 2 then yellow, and so on...
> > Was very clear how to do this in classic asp but now using the datagrid
> > control nomore...
> > I know I can use a datalist that is more flexible, but I wanna use>> > :)
> >
> > Thanks! ;)
> >
> >
>
QUASAR Guest
-
Alvin Bruney #4
Re: Change style of a single row of the item list of datagrid, based on a field value of current item...
from a scott mitchell article
Sub ItemDataBoundEventHandler(sender as Object, e as DataGridItemEventArgs)
If e.Item.ItemType = ListItemType.Item OR _
e.Item.ItemType = ListItemType.AlternatingItem then
'Check to see if the price is below a certain threshold
Dim price as Double
price = Convert.ToDouble(DataBinder.Eval(e.Item.DataItem, "price"))
If price < 10.0 then
e.Item.BackColor = System.Drawing.Color.Yellow
End If
End If
End Sub
--
Regards,
Alvin Bruney
Got tidbits? Get it here...
[url]http://tinyurl.com/3he3b[/url]
"QUASAR" <gz77@tiscali.it> wrote in message
news:%23BZpixv2DHA.1740@TK2MSFTNGP09.phx.gbl...newby> Alvin thanks a lot.
> I suppose the code given is C wich is not familiar to me (i'm a reallythe> :) )
> Can you detail a bit more in VB ?
>
> Thanks,
> Quasar ;)
>
> "Alvin Bruney" <vapor at steaming post office> ha scritto nel messaggio
> news:uR3$KKu2DHA.3140@tk2msftngp13.phx.gbl...> resume> > trap the itemdatabound event
> > if(e.item.listitemtype == listitemtype.item or alternateitem)
> > e.item.cells[0].BackColor = System.Drawing.Color.Red;
> >
> > roughly
> >
> > --
> > Regards,
> > Alvin Bruney
> > Got tidbits? Get it here...
> > [url]http://tinyurl.com/3he3b[/url]
> > "QUASAR" <gz77@tiscali.it> wrote in message
> > news:OVgy5Gu2DHA.2548@tk2msftngp13.phx.gbl...> > > Sorry for the long subject guys, but I don't know how better I can> > > the matter...
> > >
> > > Anyway, I have my datagrid showing items of an order.
> > > I want to have different backcolor of the rows based on the value ofi> > > ItemType field of the current item (datagrid row)...
> > > Example, if the current item (datagrid row) ItemType filed value is 1datagrid> > > wanna have this row backcolor red, if 2 then yellow, and so on...
> > > Was very clear how to do this in classic asp but now using the>> > datagrid> > > control nomore...
> > > I know I can use a datalist that is more flexible, but I wanna use> >> > > :)
> > >
> > > Thanks! ;)
> > >
> > >
> >
>
Alvin Bruney Guest
-
QUASAR #5
Re: Change style of a single row of the item list of datagrid, based on a field value of current item...
Thanks Alvin, I've tried but doesn't work... I give you here my code for the
sub...
What goes wrong?
Can you give me a link to the article of Scott Mitchell you mention?
Thanks, Giorgio.
----------------------------------------------------------------------------
---------
Sub ItemDataBoundEventHandler(sender as Object, e as
DataGridItemEventArgs)
If e.Item.ItemType = ListItemType.Item OR _
e.Item.ItemType = ListItemType.AlternatingItem then
'Check to see if the genre ID is 1 (Ancillary)
Dim genre As String
genre = (DataBinder.Eval(e.Item.DataItem, "_ID_genre"))
If genre > 1 then
e.Item.BackColor = System.Drawing.Color.Yellow
End If
End If
End Sub
'---------------------------------------------------------------------------
----------
"Alvin Bruney" <vapor at steaming post office> ha scritto nel messaggio
news:ulT##542DHA.2460@TK2MSFTNGP10.phx.gbl...DataGridItemEventArgs)> from a scott mitchell article
>
> Sub ItemDataBoundEventHandler(sender as Object, e as1> If e.Item.ItemType = ListItemType.Item OR _
> e.Item.ItemType = ListItemType.AlternatingItem then
> 'Check to see if the price is below a certain threshold
> Dim price as Double
> price = Convert.ToDouble(DataBinder.Eval(e.Item.DataItem, "price"))
>
> If price < 10.0 then
> e.Item.BackColor = System.Drawing.Color.Yellow
> End If
> End If
> End Sub
>
>
> --
> Regards,
> Alvin Bruney
> Got tidbits? Get it here...
> [url]http://tinyurl.com/3he3b[/url]
> "QUASAR" <gz77@tiscali.it> wrote in message
> news:%23BZpixv2DHA.1740@TK2MSFTNGP09.phx.gbl...> newby> > Alvin thanks a lot.
> > I suppose the code given is C wich is not familiar to me (i'm a really> the> > :) )
> > Can you detail a bit more in VB ?
> >
> > Thanks,
> > Quasar ;)
> >
> > "Alvin Bruney" <vapor at steaming post office> ha scritto nel messaggio
> > news:uR3$KKu2DHA.3140@tk2msftngp13.phx.gbl...> > resume> > > trap the itemdatabound event
> > > if(e.item.listitemtype == listitemtype.item or alternateitem)
> > > e.item.cells[0].BackColor = System.Drawing.Color.Red;
> > >
> > > roughly
> > >
> > > --
> > > Regards,
> > > Alvin Bruney
> > > Got tidbits? Get it here...
> > > [url]http://tinyurl.com/3he3b[/url]
> > > "QUASAR" <gz77@tiscali.it> wrote in message
> > > news:OVgy5Gu2DHA.2548@tk2msftngp13.phx.gbl...
> > > > Sorry for the long subject guys, but I don't know how better I can> > > > the matter...
> > > >
> > > > Anyway, I have my datagrid showing items of an order.
> > > > I want to have different backcolor of the rows based on the value of> > > > ItemType field of the current item (datagrid row)...
> > > > Example, if the current item (datagrid row) ItemType filed value is> i> datagrid> > > > wanna have this row backcolor red, if 2 then yellow, and so on...
> > > > Was very clear how to do this in classic asp but now using the>> >> > > > control nomore...
> > > > I know I can use a datalist that is more flexible, but I wanna use
> > > datagrid
> > > > :)
> > > >
> > > > Thanks! ;)
> > > >
> > > >
> > >
> > >
> >
>
QUASAR Guest
-
QUASAR #6
Re: Change style of a single row of the item list of datagrid, based on a field value of current item...
Change color of a single row of the item list of datagrid, based on a field
value of current item...
Now I'm trying with this code but without success again :((
What is wrong?
No one can help???
Thanks :)
'---------------------------------------------------------------------------
Sub ItemGrid_ItemDataBound(ByVal source As Object, ByVal e As
DataGridItemEventArgs)
' OR ALSO I'VE TRYED Sub ItemGrid_ItemDataBound(sender as Object, e as
DataGridItemEventArgs)
If (e.Item.ItemType = ListItemType.Item Or e.Item.ItemType =
ListItemType.AlternatingItem) Then
If e.Item.DataItem("_ID_genre") < 2 Then
' genre is "ancillary equipment"
e.Item.BackColor = System.Drawing.Color.Yellow
e.Item.Cells.Item(0).BackColor =
System.Drawing.Color.FromName("Green")
End If
End If
End Sub
'---------------------------------------------------------------------------
"QUASAR" <gz77@tiscali.it> ha scritto nel messaggio
news:OVgy5Gu2DHA.2548@tk2msftngp13.phx.gbl...datagrid> Sorry for the long subject guys, but I don't know how better I can resume
> the matter...
>
> Anyway, I have my datagrid showing items of an order.
> I want to have different backcolor of the rows based on the value of the
> ItemType field of the current item (datagrid row)...
> Example, if the current item (datagrid row) ItemType filed value is 1 i
> wanna have this row backcolor red, if 2 then yellow, and so on...
> Was very clear how to do this in classic asp but now using the datagrid
> control nomore...
> I know I can use a datalist that is more flexible, but I wanna use> :)
>
> Thanks! ;)
>
>
QUASAR Guest
-
QUASAR #7
Re: Change style of a single row of the item list of datagrid, based on a field value of current item...
Ok now it works...
was my fault, I've not setted in the datagrid properties the
"OnItemDataBound" event...
If someone may have the same need the final code was here...
Insert the sub and don't forgot to set in the datagrid properties the
"OnItemDataBound" event
<asp:DataGrid id="DataGrid1"...
....OnItemDataBound="DataGrid1_ItemDataBoundEvent"
'---------------------------------------------------------------------------
----------
Sub DataGrid1_ItemDataBoundEvent(sender as Object, e as
DataGridItemEventArgs)
If e.Item.ItemType = ListItemType.Item _
OR e.Item.ItemType = ListItemType.AlternatingItem then
'Check to see if the genre ID is 1 (Ancillary)
If e.Item.DataItem("_ID_Tipo_Item") < 2 Then
e.Item.BackColor = System.Drawing.Color.FromName("Lavender")
End If
End If
End Sub
'---------------------------------------------------------------------------
----------
Byez,
Giorgio
"QUASAR" <gz77@tiscali.it> ha scritto nel messaggio
news:OVgy5Gu2DHA.2548@tk2msftngp13.phx.gbl...datagrid> Sorry for the long subject guys, but I don't know how better I can resume
> the matter...
>
> Anyway, I have my datagrid showing items of an order.
> I want to have different backcolor of the rows based on the value of the
> ItemType field of the current item (datagrid row)...
> Example, if the current item (datagrid row) ItemType filed value is 1 i
> wanna have this row backcolor red, if 2 then yellow, and so on...
> Was very clear how to do this in classic asp but now using the datagrid
> control nomore...
> I know I can use a datalist that is more flexible, but I wanna use> :)
>
> Thanks! ;)
>
>
QUASAR Guest



Reply With Quote

