Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > datagrid

Reply
Thread Tools

datagrid

 
 
Trond
Guest
Posts: n/a
 
      04-18-2005
I have a form with a datagrid that is databound. One of the column is like
this:

<asp:BoundColumn DataField="Timediff"
SortExpression="Timediff"
HeaderText="Time difference">
<HeaderStyle Wrap="False"></HeaderStyle>
</asp:BoundColumn>

In that column i display a number from 0 to 3 mill

Is there a way i can replace that with graphics?
If number is < 60 then green
if number is = 60 then yellow
if number is > 60 then red

best regards
Trond


 
Reply With Quote
 
 
 
 
=?Utf-8?B?RGF2ZSBCcml0dG9u?=
Guest
Posts: n/a
 
      04-18-2005
Best bet would be to set this up as a template column and put a control in
there that you can colour. Then in the item_create event for the grid, you
could check the value for this specific row/col and set the colour of the
control accordingly

Dave

"Trond" wrote:

> I have a form with a datagrid that is databound. One of the column is like
> this:
>
> <asp:BoundColumn DataField="Timediff"
> SortExpression="Timediff"
> HeaderText="Time difference">
> <HeaderStyle Wrap="False"></HeaderStyle>
> </asp:BoundColumn>
>
> In that column i display a number from 0 to 3 mill
>
> Is there a way i can replace that with graphics?
> If number is < 60 then green
> if number is = 60 then yellow
> if number is > 60 then red
>
> best regards
> Trond
>
>
>

 
Reply With Quote
 
 
 
 
=?Utf-8?B?RWx0b24gVw==?=
Guest
Posts: n/a
 
      04-18-2005
Hi Trond,

You can process in DataGrid_ItemDataBound event:

if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType ==
ListItemType.AlternatingItem)
{
TableCell cell = e.Item.Cells[TimediffIndex];
double Timediff = double.Parse(cell.Text);
if (Timediff == 60)
{
cell.BackColor = Color.Yellow;
}
else
{
if (Timediff < 60)
{
cell.BackColor = Color.Green;
}
else
{
cell.BackColor = Color.Red;
}
}
}


HTH

Elton Wang
http://www.velocityreviews.com/forums/(E-Mail Removed)



"Trond" wrote:

> I have a form with a datagrid that is databound. One of the column is like
> this:
>
> <asp:BoundColumn DataField="Timediff"
> SortExpression="Timediff"
> HeaderText="Time difference">
> <HeaderStyle Wrap="False"></HeaderStyle>
> </asp:BoundColumn>
>
> In that column i display a number from 0 to 3 mill
>
> Is there a way i can replace that with graphics?
> If number is < 60 then green
> if number is = 60 then yellow
> if number is > 60 then red
>
> best regards
> Trond
>
>
>

 
Reply With Quote
 
Trond
Guest
Posts: n/a
 
      04-19-2005
Thank you so much. What is TimediffIndex? The code reports an error with
that saying: The name 'TimediffIndex' does not exist in the class or
namespace

best regards
Trond


"Elton W" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Hi Trond,
>
> You can process in DataGrid_ItemDataBound event:
>
> if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType ==
> ListItemType.AlternatingItem)
> {
> TableCell cell = e.Item.Cells[TimediffIndex];
> double Timediff = double.Parse(cell.Text);
> if (Timediff == 60)
> {
> cell.BackColor = Color.Yellow;
> }
> else
> {
> if (Timediff < 60)
> {
> cell.BackColor = Color.Green;
> }
> else
> {
> cell.BackColor = Color.Red;
> }
> }
> }
>
>
> HTH
>
> Elton Wang
> (E-Mail Removed)
>
>
>
> "Trond" wrote:
>
>> I have a form with a datagrid that is databound. One of the column is
>> like
>> this:
>>
>> <asp:BoundColumn DataField="Timediff"
>> SortExpression="Timediff"
>> HeaderText="Time difference">
>> <HeaderStyle Wrap="False"></HeaderStyle>
>> </asp:BoundColumn>
>>
>> In that column i display a number from 0 to 3 mill
>>
>> Is there a way i can replace that with graphics?
>> If number is < 60 then green
>> if number is = 60 then yellow
>> if number is > 60 then red
>>
>> best regards
>> Trond
>>
>>
>>



 
Reply With Quote
 
=?Utf-8?B?RWx0b24gVw==?=
Guest
Posts: n/a
 
      04-19-2005
TimediffIndex means the index of your Timediff column, e.g. 0 for the first
column.

HTH

Elton Wang

"Trond" wrote:

> Thank you so much. What is TimediffIndex? The code reports an error with
> that saying: The name 'TimediffIndex' does not exist in the class or
> namespace
>
> best regards
> Trond
>
>
> "Elton W" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
> > Hi Trond,
> >
> > You can process in DataGrid_ItemDataBound event:
> >
> > if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType ==
> > ListItemType.AlternatingItem)
> > {
> > TableCell cell = e.Item.Cells[TimediffIndex];
> > double Timediff = double.Parse(cell.Text);
> > if (Timediff == 60)
> > {
> > cell.BackColor = Color.Yellow;
> > }
> > else
> > {
> > if (Timediff < 60)
> > {
> > cell.BackColor = Color.Green;
> > }
> > else
> > {
> > cell.BackColor = Color.Red;
> > }
> > }
> > }
> >
> >
> > HTH
> >
> > Elton Wang
> > (E-Mail Removed)
> >
> >
> >
> > "Trond" wrote:
> >
> >> I have a form with a datagrid that is databound. One of the column is
> >> like
> >> this:
> >>
> >> <asp:BoundColumn DataField="Timediff"
> >> SortExpression="Timediff"
> >> HeaderText="Time difference">
> >> <HeaderStyle Wrap="False"></HeaderStyle>
> >> </asp:BoundColumn>
> >>
> >> In that column i display a number from 0 to 3 mill
> >>
> >> Is there a way i can replace that with graphics?
> >> If number is < 60 then green
> >> if number is = 60 then yellow
> >> if number is > 60 then red
> >>
> >> best regards
> >> Trond
> >>
> >>
> >>

>
>
>

 
Reply With Quote
 
Trond
Guest
Posts: n/a
 
      04-19-2005
Yes I see. Thank you. I changed it to the column number and presto,
everything is working fine.
As a newbie I really appreciate that you took time to write code
Best regards
Trond

"Elton W" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> TimediffIndex means the index of your Timediff column, e.g. 0 for the
> first
> column.
>
> HTH
>
> Elton Wang
>
> "Trond" wrote:
>
>> Thank you so much. What is TimediffIndex? The code reports an error with
>> that saying: The name 'TimediffIndex' does not exist in the class or
>> namespace
>>
>> best regards
>> Trond
>>
>>
>> "Elton W" <(E-Mail Removed)> wrote in message
>> news:(E-Mail Removed)...
>> > Hi Trond,
>> >
>> > You can process in DataGrid_ItemDataBound event:
>> >
>> > if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType ==
>> > ListItemType.AlternatingItem)
>> > {
>> > TableCell cell = e.Item.Cells[TimediffIndex];
>> > double Timediff = double.Parse(cell.Text);
>> > if (Timediff == 60)
>> > {
>> > cell.BackColor = Color.Yellow;
>> > }
>> > else
>> > {
>> > if (Timediff < 60)
>> > {
>> > cell.BackColor = Color.Green;
>> > }
>> > else
>> > {
>> > cell.BackColor = Color.Red;
>> > }
>> > }
>> > }
>> >
>> >
>> > HTH
>> >
>> > Elton Wang
>> > (E-Mail Removed)
>> >
>> >
>> >
>> > "Trond" wrote:
>> >
>> >> I have a form with a datagrid that is databound. One of the column is
>> >> like
>> >> this:
>> >>
>> >> <asp:BoundColumn DataField="Timediff"
>> >> SortExpression="Timediff"
>> >> HeaderText="Time difference">
>> >> <HeaderStyle Wrap="False"></HeaderStyle>
>> >> </asp:BoundColumn>
>> >>
>> >> In that column i display a number from 0 to 3 mill
>> >>
>> >> Is there a way i can replace that with graphics?
>> >> If number is < 60 then green
>> >> if number is = 60 then yellow
>> >> if number is > 60 then red
>> >>
>> >> best regards
>> >> Trond
>> >>
>> >>
>> >>

>>
>>
>>



 
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
Re: Datagrid: how cut short display of a long description in a datagrid column Brian K. Williams ASP .Net 0 03-02-2004 08:35 PM
RE: Datagrid: how cut short display of a long description in a datagrid column =?Utf-8?B?U3VyZXNo?= ASP .Net 0 03-02-2004 08:31 PM
datagrid in datagrid BK Kim ASP .Net 1 03-02-2004 06:34 AM
Call Datagrid Command column outside datagrid Dave ASP .Net 0 11-20-2003 11:11 AM
To all Gurus: How can I edit/update a DataGrid in a DataGrid (nested DataGrid)? Possible? Andreas Klemt ASP .Net Datagrid Control 0 10-08-2003 01:19 AM



Advertisments