|
.net
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Color not displaying in dropdown listand this is how it is suggested to do this in a couple of articles. I have a DropDownList call PayDates and I was going to set any row not in my DataSet to Red. PayDates.Items[3].Attributes.Add("style", "color:red"); for(ktr=1;ktr<= PayDates.Items.Count - 1;ktr++)// { rows = BatchIDDataSet.Tables[0].Select("BatchID = '" + PayDates.Items[ktr].Text.Substring(0,PayDates.Items[ktr].Text.IndexOf(" /")) + "'"); if (rows.Length > 0) PayDates.Items[ktr].Attributes.Add("style", "color:red"); } In this case all the rows, except the 1st one should be Red. The debug showed the rows.length to be 1 for all these rows. But the color was still black and the viewsource showed that there was no Style attribute anywhere. So when this didn't work, I tried to add a specific row and not do the For/Loop: PayDates.Items[3].Attributes.Add("style", "color:red"); So that only row one would be red. This didn't work either. What am I missing? The data is there - just all black. Thanks, If what you want is like : http://asp.net.do/test/dropdowncolor.aspx
....all you need to do is add : <option style="color: blue;">One</option> to your options. Here's a handy list of HTML color names : http://www.w3schools.com/html/html_colornames.asp Juan T. Llibre, asp.net MVP aspnetfaq.com : http://www.aspnetfaq.com/ asp.net faq : http://asp.net.do/faq/ foros de asp.net, en español : http://asp.net.do/foros/ =================================== Show quote "tshad" <tscheider***@ftsolutions.com> wrote in message news:%23Xwqtdp0GHA.1252@TK2MSFTNGP04.phx.gbl... >I am trying to add a different color to some of the rows in my dropdown list and this is how it is >suggested to do this in a couple of articles. > > I have a DropDownList call PayDates and I was going to set any row not in my DataSet to Red. > > PayDates.Items[3].Attributes.Add("style", "color:red"); > > for(ktr=1;ktr<= PayDates.Items.Count - 1;ktr++)// > { > rows = BatchIDDataSet.Tables[0].Select("BatchID = '" + > PayDates.Items[ktr].Text.Substring(0,PayDates.Items[ktr].Text.IndexOf(" /")) + "'"); > if (rows.Length > 0) > PayDates.Items[ktr].Attributes.Add("style", "color:red"); > } > > In this case all the rows, except the 1st one should be Red. The debug showed the rows.length to > be 1 for all these rows. But the color was still black and the viewsource showed that there was > no Style attribute anywhere. > > So when this didn't work, I tried to add a specific row and not do the For/Loop: > > PayDates.Items[3].Attributes.Add("style", "color:red"); > > So that only row one would be red. This didn't work either. > > What am I missing? The data is there - just all black. > > Thanks, > > "Juan T. Llibre" <nomailrepl***@nowhere.com> wrote in message That is what:news:uT2Exyp0GHA.4632@TK2MSFTNGP03.phx.gbl... > If what you want is like : http://asp.net.do/test/dropdowncolor.aspx > > ...all you need to do is add : > > <option style="color: blue;">One</option> > to your options. PayDates.Items[3].Attributes.Add("style", "color:red"); is supposed to do according to these links: http://www.c-sharpcorner.com/Code/2003/July/ColorFullDropDown.asp http://www.c-sharpcorner.com/Code/2003/July/DropDownListBox.asp The dropdown list is: <asp:dropdownlist id="PayDates" runat="server"></asp:dropdownlist> The displayed web page is: <select name="PayDates" id="PayDates"> <option value="Select Date">Select Date</option> <option value="09-08-2006">2006117 / 09-08-2006 / 09-08-06 Bi-weekly</option> <option value="08-25-2006">V089669 / 08-25-2006 / Reverse Voucher Number 089502</option> <option value="08-25-2006">2006113 / 08-25-2006 / 08-25-06 Bi-weekly</option> <option value="08-18-2006">2006116 / 08-18-2006 / Supp H.ortiz/final Chk</option> .... As you can see there is no style attribute. The ".Attributes.Add" code is done at the end of the Sub after the DataBind. Thanks, Tom Show quote > > Here's a handy list of HTML color names : > http://www.w3schools.com/html/html_colornames.asp > > > > Juan T. Llibre, asp.net MVP > aspnetfaq.com : http://www.aspnetfaq.com/ > asp.net faq : http://asp.net.do/faq/ > foros de asp.net, en español : http://asp.net.do/foros/ > =================================== > "tshad" <tscheider***@ftsolutions.com> wrote in message > news:%23Xwqtdp0GHA.1252@TK2MSFTNGP04.phx.gbl... >>I am trying to add a different color to some of the rows in my dropdown >>list and this is how it is suggested to do this in a couple of articles. >> >> I have a DropDownList call PayDates and I was going to set any row not in >> my DataSet to Red. >> >> PayDates.Items[3].Attributes.Add("style", "color:red"); >> >> for(ktr=1;ktr<= PayDates.Items.Count - 1;ktr++)// >> { >> rows = BatchIDDataSet.Tables[0].Select("BatchID = '" + >> PayDates.Items[ktr].Text.Substring(0,PayDates.Items[ktr].Text.IndexOf(" >> /")) + "'"); >> if (rows.Length > 0) >> PayDates.Items[ktr].Attributes.Add("style", "color:red"); >> } >> >> In this case all the rows, except the 1st one should be Red. The debug >> showed the rows.length to be 1 for all these rows. But the color was >> still black and the viewsource showed that there was no Style attribute >> anywhere. >> >> So when this didn't work, I tried to add a specific row and not do the >> For/Loop: >> >> PayDates.Items[3].Attributes.Add("style", "color:red"); >> >> So that only row one would be red. This didn't work either. >> >> What am I missing? The data is there - just all black. >> >> Thanks, >> >> > > |
|||||||||||||||||||||||