|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Template column base on another column valueI 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>"; } } 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----- on the value of> >Hello .net expert, >I would like to change the color a a column "Name" base >another column "tel" . Is it possible ??? (Container.DataItem,"XTEL"))%>> >Thanks in advance !! >Esperanza > > ><ItemTemplate> > <b> > <%#CustomColorRow(DataBinder.Eval 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>"; > } >} > > >. > 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>"; > > } > >} > > > > > >. > > Use
e.Item.Cells[6]/[9] and so on. HTH Elton Wang >-----Original Message----- 'property' where a>It seems to generate a problem >Error message : >'System.Web.UI.WebControls.TableRow.Cells' denotes a Show quoteHide quote >'method' was expected dans le message> >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 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>"; >> > } >> >} >> > >> > >> >. >> > > > >. > 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 e.Item.Cells[6]/[9] and so on.de news:022401c51691$6439b660$a601280a@phx.gbl... Use HTH Elton Wang >-----Original Message----- 'property' where a>It seems to generate a problem >Error message : >'System.Web.UI.WebControls.TableRow.Cells' denotes a Show quoteHide quote >'method' was expected dans le message> >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 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>"; >> > } >> >} >> > >> > >> >. >> > > > >. > 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----- écrit dans le 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 Show quoteHide quote >de news:022401c51691$6439b660$a601280a@phx.gbl... color:white;\">">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- Show quoteHide quote >>> +indiceAppel + >>> >"</span>"; >>> > } >>> >} >>> > >>> > >>> >. >>> > >> >> >>. >> > > >. >
Adding "delete" functionality in DataGrid - without a ButtonColumn
Add additional row into header? getting the data for dynamically for Datagrid bound columns of a datagrid How To Insert ASP.NET User Control into DataGrid Column? DataGrid with Dropdown list Need to Format a zipcode into xxxxx-xxxx. How to add javascript onClick attribute to datagrid's edit template (update command)? Why doesn't the CssClass property change the visual display of my datagrid cells? Datagrid colum has no Dataformat property |
|||||||||||||||||||||||