473,366 Members | 1,120 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,366 software developers and data experts.

Color not displaying in dropdown list

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,
Sep 7 '06 #1
2 1612
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/
===================================
"tshad" <ts**********@ftsolutions.comwrote in message
news:%2****************@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,


Sep 7 '06 #2
"Juan T. Llibre" <no***********@nowhere.comwrote in message
news:uT**************@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.
That is what:

PayDates.Items[3].Attributes.Add("style", "color:red");

is supposed to do according to these links:

http://www.c-sharpcorner.com/Code/20...llDropDown.asp
http://www.c-sharpcorner.com/Code/20...ownListBox.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
>
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" <ts**********@ftsolutions.comwrote in message
news:%2****************@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,



Sep 8 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Joseph Barron | last post by:
Here is a SIMPLE problem that I'm trying to solve. It works in Netscape 6.2, but IE6 gives ""No such interface supported." Below are page1.htm and page2.htm . In page1.htm, there are two...
3
by: Deepa | last post by:
Hi Am doing a web app which has a datagrid with template columns. One of the columns has dropdowns for each row. I also have the EditCommandColumn. The problem am facing is I just see the last...
2
by: Irishmaninusa | last post by:
Hello Everyone, I am populating a dropdown control from a database where the data is datetime values. In my stored procedure I am ordering them by where the most recent is at the top and the...
0
by: polaris431 | last post by:
I would like to have a combobox control that when clicked, displays a DataGridView in-place of the normal dropdown list. I want it to be a DataGridView with editing capabilities. The DataGridView...
0
by: er1 | last post by:
Hi All, I am trying populate dropdownlist using SQL query. I am able to bind the list and populate it with query result. But in Dropdown list it shows 1st result of a query as a default value. I...
2
by: max | last post by:
Hello, I have a VS2005 framework and ado.net. I have an access db with two tables: 1) Patients; 2) Doctors. The 'Patients table is already filled by a long list of records (coming from an old...
4
by: Panna | last post by:
Hey there I am using phpMyAdmin and MySQL to develop a dbase application. I have a dropdown menu on one of the pages which gets populated automatically with data from a table in the database....
8
by: bimeldip | last post by:
Hi, i would like to display the list of tables in a database in a drop down list then when user selects a table, the table will be dispalyed on the page. So far i've done this: <? $dbname =...
2
by: Bill Fuller | last post by:
I have a dropdown combo box where the DataSource is bound to a CSLA BO returned from a WCF call. The dropdown list looks fine, but selecting an item returns...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.