Home All Groups Group Topic Archive Search About

Template column base on another column value

Author
18 Feb 2005 3:22 PM
Esperanza
Hello .net expert,
I would like to change the color a a column "Name" base on the value  of
another column "tel" . Is it possible ???

Thanks in advance !!
Esperanza


<ItemTemplate>
       <b>
        <%#CustomColorRow(DataBinder.Eval(Container.DataItem,"XTEL"))%>
       </b>
      </ItemTemplate>

'=============================================
public string CustomColorRow(object indiceAppel)
  {
   if (indiceAppel.Equals("5147426101"))

   {
   return "<span style=\"background-color:blue;\">" +indiceAppel +
"</span>";
   }
else
    {  return "<span style=\"background-color:white;\">" +indiceAppel +
"</span>";
    }
}

Author
18 Feb 2005 5:05 PM
Elton Wang
Yes.

In datagrid_ItemCreated

ListItemType itemType = e.Item.ItemType;

if (itemType == ListItemType.Header){
    TableCell cell = e.Item.Cells(index1);
    TableCell cell1 = e.Item.Cells(index2); // 
column "tel"
    if (cell1.Text.Equals("Something")){
        cell.Text = ...;
        cell.BackColor = Color.somecolor;
    }
}

HTH,

Elton Wang
elton_w***@hotmail.com

>-----Original Message-----
>
>Hello .net expert,
>I would like to change the color a a column "Name" base
on the value  of
>another column "tel" . Is it possible ???
>
>Thanks in advance !!
>Esperanza
>
>
><ItemTemplate>
>       <b>
>        <%#CustomColorRow(DataBinder.Eval
(Container.DataItem,"XTEL"))%>
Show quoteHide quote
>       </b>
>      </ItemTemplate>
>
>'=============================================
>public string CustomColorRow(object indiceAppel)
>  {
>   if (indiceAppel.Equals("5147426101"))
>
>   {
>   return "<span style=\"background-color:blue;\">"
+indiceAppel +
>"</span>";
>   }
>else
>    {  return "<span style=\"background-color:white;\">"
+indiceAppel +
>"</span>";
>    }
>}
>
>
>.
>
Author
18 Feb 2005 8:00 PM
Esperanza
It seems to generate a problem
Error message :
'System.Web.UI.WebControls.TableRow.Cells' denotes a 'property' where a
'method' was expected

am I missing something ?



private void DataGrid1_ItemCreated(object sender,
System.Web.UI.WebControls.DataGridItemEventArgs e)
  {
   ListItemType itemType = e.Item.ItemType;
   if (itemType == ListItemType.Header)
   {
    TableCell cell = e.Item.Cells(6); //Client
    TableCell cell1 = e.Item.Cells(9);//Phone
    if (cell1.Text.Equals("4442221212"))
    {
     cell.BackColor = Color.LightBlue;
    }
   }

  }
Show quoteHide quote
"Elton Wang" <anonym***@discussions.microsoft.com> a écrit dans le message
de news:159901c515dc$15e49ee0$a401280a@phx.gbl...
> Yes.
>
> In datagrid_ItemCreated
>
> ListItemType itemType = e.Item.ItemType;
>
> if (itemType == ListItemType.Header){
>     TableCell cell = e.Item.Cells(index1);
>     TableCell cell1 = e.Item.Cells(index2); //
> column "tel"
>     if (cell1.Text.Equals("Something")){
>         cell.Text = ...;
>         cell.BackColor = Color.somecolor;
>     }
> }
>
> HTH,
>
> Elton Wang
> elton_w***@hotmail.com
>
> >-----Original Message-----
> >
> >Hello .net expert,
> >I would like to change the color a a column "Name" base
> on the value  of
> >another column "tel" . Is it possible ???
> >
> >Thanks in advance !!
> >Esperanza
> >
> >
> ><ItemTemplate>
> >       <b>
> >        <%#CustomColorRow(DataBinder.Eval
> (Container.DataItem,"XTEL"))%>
> >       </b>
> >      </ItemTemplate>
> >
> >'=============================================
> >public string CustomColorRow(object indiceAppel)
> >  {
> >   if (indiceAppel.Equals("5147426101"))
> >
> >   {
> >   return "<span style=\"background-color:blue;\">"
> +indiceAppel +
> >"</span>";
> >   }
> >else
> >    {  return "<span style=\"background-color:white;\">"
> +indiceAppel +
> >"</span>";
> >    }
> >}
> >
> >
> >.
> >
Author
19 Feb 2005 2:43 PM
Elton Wang
Use
e.Item.Cells[6]/[9] and so on.

HTH

Elton Wang

>-----Original Message-----
>It seems to generate a problem
>Error message :
>'System.Web.UI.WebControls.TableRow.Cells' denotes a
'property' where a
Show quoteHide quote
>'method' was expected
>
>am I missing something ?
>
>
>
>private void DataGrid1_ItemCreated(object sender,
>System.Web.UI.WebControls.DataGridItemEventArgs e)
>  {
>   ListItemType itemType = e.Item.ItemType;
>   if (itemType == ListItemType.Header)
>   {
>    TableCell cell = e.Item.Cells(6); //Client
>    TableCell cell1 = e.Item.Cells(9);//Phone
>    if (cell1.Text.Equals("4442221212"))
>    {
>     cell.BackColor = Color.LightBlue;
>    }
>   }
>
>  }
>"Elton Wang" <anonym***@discussions.microsoft.com> a écrit
dans le message
Show quoteHide quote
>de news:159901c515dc$15e49ee0$a401280a@phx.gbl...
>> Yes.
>>
>> In datagrid_ItemCreated
>>
>> ListItemType itemType = e.Item.ItemType;
>>
>> if (itemType == ListItemType.Header){
>>     TableCell cell = e.Item.Cells(index1);
>>     TableCell cell1 = e.Item.Cells(index2); //
>> column "tel"
>>     if (cell1.Text.Equals("Something")){
>>         cell.Text = ...;
>>         cell.BackColor = Color.somecolor;
>>     }
>> }
>>
>> HTH,
>>
>> Elton Wang
>> elton_w***@hotmail.com
>>
>> >-----Original Message-----
>> >
>> >Hello .net expert,
>> >I would like to change the color a a column "Name" base
>> on the value  of
>> >another column "tel" . Is it possible ???
>> >
>> >Thanks in advance !!
>> >Esperanza
>> >
>> >
>> ><ItemTemplate>
>> >       <b>
>> >        <%#CustomColorRow(DataBinder.Eval
>> (Container.DataItem,"XTEL"))%>
>> >       </b>
>> >      </ItemTemplate>
>> >
>> >'=============================================
>> >public string CustomColorRow(object indiceAppel)
>> >  {
>> >   if (indiceAppel.Equals("5147426101"))
>> >
>> >   {
>> >   return "<span style=\"background-color:blue;\">"
>> +indiceAppel +
>> >"</span>";
>> >   }
>> >else
>> >    {  return "<span style=\"background-color:white;\">"
>> +indiceAppel +
>> >"</span>";
>> >    }
>> >}
>> >
>> >
>> >.
>> >
>
>
>.
>
Author
21 Feb 2005 3:46 PM
Esperanza
Me again,
Ok, now I can compile without problem,
I'm going step by step into the code and I realized that
it compared the header value instead of the value of the cell.
cell1.Text = "Phone" so
"Phone" never equal 514-222-1111

so the phone number backcolor never changed color.

Thanks in advance !!
Esperanza


'==============================
ListItemType itemType = e.Item.ItemType;
   if (itemType == ListItemType.Header)
   {
    TableCell cell = e.Item.Cells[6]; //Client
    TableCell cell1 = e.Item.Cells[9];//Phone
    if (cell1.Text.Equals(514-222-1111))
    {
     cell.BackColor = Color.LightBlue;
    }
   }



"Elton Wang" <anonym***@discussions.microsoft.com> a écrit dans le message
de news:022401c51691$6439b660$a601280a@phx.gbl...
Use
e.Item.Cells[6]/[9] and so on.

HTH

Elton Wang

>-----Original Message-----
>It seems to generate a problem
>Error message :
>'System.Web.UI.WebControls.TableRow.Cells' denotes a
'property' where a
Show quoteHide quote
>'method' was expected
>
>am I missing something ?
>
>
>
>private void DataGrid1_ItemCreated(object sender,
>System.Web.UI.WebControls.DataGridItemEventArgs e)
>  {
>   ListItemType itemType = e.Item.ItemType;
>   if (itemType == ListItemType.Header)
>   {
>    TableCell cell = e.Item.Cells(6); //Client
>    TableCell cell1 = e.Item.Cells(9);//Phone
>    if (cell1.Text.Equals("4442221212"))
>    {
>     cell.BackColor = Color.LightBlue;
>    }
>   }
>
>  }
>"Elton Wang" <anonym***@discussions.microsoft.com> a écrit
dans le message
Show quoteHide quote
>de news:159901c515dc$15e49ee0$a401280a@phx.gbl...
>> Yes.
>>
>> In datagrid_ItemCreated
>>
>> ListItemType itemType = e.Item.ItemType;
>>
>> if (itemType == ListItemType.Header){
>>     TableCell cell = e.Item.Cells(index1);
>>     TableCell cell1 = e.Item.Cells(index2); //
>> column "tel"
>>     if (cell1.Text.Equals("Something")){
>>         cell.Text = ...;
>>         cell.BackColor = Color.somecolor;
>>     }
>> }
>>
>> HTH,
>>
>> Elton Wang
>> elton_w***@hotmail.com
>>
>> >-----Original Message-----
>> >
>> >Hello .net expert,
>> >I would like to change the color a a column "Name" base
>> on the value  of
>> >another column "tel" . Is it possible ???
>> >
>> >Thanks in advance !!
>> >Esperanza
>> >
>> >
>> ><ItemTemplate>
>> >       <b>
>> >        <%#CustomColorRow(DataBinder.Eval
>> (Container.DataItem,"XTEL"))%>
>> >       </b>
>> >      </ItemTemplate>
>> >
>> >'=============================================
>> >public string CustomColorRow(object indiceAppel)
>> >  {
>> >   if (indiceAppel.Equals("5147426101"))
>> >
>> >   {
>> >   return "<span style=\"background-color:blue;\">"
>> +indiceAppel +
>> >"</span>";
>> >   }
>> >else
>> >    {  return "<span style=\"background-color:white;\">"
>> +indiceAppel +
>> >"</span>";
>> >    }
>> >}
>> >
>> >
>> >.
>> >
>
>
>.
>
Author
21 Feb 2005 4:02 PM
Elton Wang
Yes. The code sample is only for Header. If you want for
items, you should do something like

if(itemType != ListItemType.Header && itemType !=
ListItemType.Pager && itemType != ListItemType.Footer &&
itemType != ListItemType.Seperator){
   // code here
}

HTH,

Elton

Show quoteHide quote
>-----Original Message-----
>Me again,
>Ok, now I can compile without problem,
>I'm going step by step into the code and I realized that
>it compared the header value instead of the value of the
cell.
>cell1.Text = "Phone" so
>"Phone" never equal 514-222-1111
>
>so the phone number backcolor never changed color.
>
>Thanks in advance !!
>Esperanza
>
>
>'==============================
>ListItemType itemType = e.Item.ItemType;
>   if (itemType == ListItemType.Header)
>   {
>    TableCell cell = e.Item.Cells[6]; //Client
>    TableCell cell1 = e.Item.Cells[9];//Phone
>    if (cell1.Text.Equals(514-222-1111))
>    {
>     cell.BackColor = Color.LightBlue;
>    }
>   }
>
>
>
>"Elton Wang" <anonym***@discussions.microsoft.com> a
écrit dans le message
Show quoteHide quote
>de news:022401c51691$6439b660$a601280a@phx.gbl...
>Use
>e.Item.Cells[6]/[9] and so on.
>
>HTH
>
>Elton Wang
>
>>-----Original Message-----
>>It seems to generate a problem
>>Error message :
>>'System.Web.UI.WebControls.TableRow.Cells' denotes a
>'property' where a
>>'method' was expected
>>
>>am I missing something ?
>>
>>
>>
>>private void DataGrid1_ItemCreated(object sender,
>>System.Web.UI.WebControls.DataGridItemEventArgs e)
>>  {
>>   ListItemType itemType = e.Item.ItemType;
>>   if (itemType == ListItemType.Header)
>>   {
>>    TableCell cell = e.Item.Cells(6); //Client
>>    TableCell cell1 = e.Item.Cells(9);//Phone
>>    if (cell1.Text.Equals("4442221212"))
>>    {
>>     cell.BackColor = Color.LightBlue;
>>    }
>>   }
>>
>>  }
>>"Elton Wang" <anonym***@discussions.microsoft.com> a
écrit
>dans le message
>>de news:159901c515dc$15e49ee0$a401280a@phx.gbl...
>>> Yes.
>>>
>>> In datagrid_ItemCreated
>>>
>>> ListItemType itemType = e.Item.ItemType;
>>>
>>> if (itemType == ListItemType.Header){
>>>     TableCell cell = e.Item.Cells(index1);
>>>     TableCell cell1 = e.Item.Cells(index2); //
>>> column "tel"
>>>     if (cell1.Text.Equals("Something")){
>>>         cell.Text = ...;
>>>         cell.BackColor = Color.somecolor;
>>>     }
>>> }
>>>
>>> HTH,
>>>
>>> Elton Wang
>>> elton_w***@hotmail.com
>>>
>>> >-----Original Message-----
>>> >
>>> >Hello .net expert,
>>> >I would like to change the color a a column "Name"
base
>>> on the value  of
>>> >another column "tel" . Is it possible ???
>>> >
>>> >Thanks in advance !!
>>> >Esperanza
>>> >
>>> >
>>> ><ItemTemplate>
>>> >       <b>
>>> >        <%#CustomColorRow(DataBinder.Eval
>>> (Container.DataItem,"XTEL"))%>
>>> >       </b>
>>> >      </ItemTemplate>
>>> >
>>> >'=============================================
>>> >public string CustomColorRow(object indiceAppel)
>>> >  {
>>> >   if (indiceAppel.Equals("5147426101"))
>>> >
>>> >   {
>>> >   return "<span style=\"background-color:blue;\">"
>>> +indiceAppel +
>>> >"</span>";
>>> >   }
>>> >else
>>> >    {  return "<span style=\"background-
color:white;\">"
Show quoteHide quote
>>> +indiceAppel +
>>> >"</span>";
>>> >    }
>>> >}
>>> >
>>> >
>>> >.
>>> >
>>
>>
>>.
>>
>
>
>.
>