T
tshad
Is there a way to set one item in a dropdown list to a different color?
I have a case where I might have 15 items and one is a default and would
like to set the default as green where all the rest are black.
I looked at the examples from
http://www.c-sharpcorner.com/Code/2003/July/ColorFullDropDown.asp and
http://www.c-sharpcorner.com/Code/2003/July/DropDownListBox.asp but I can't
seem to get it to work.
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:
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,
Tom
I have a case where I might have 15 items and one is a default and would
like to set the default as green where all the rest are black.
I looked at the examples from
http://www.c-sharpcorner.com/Code/2003/July/ColorFullDropDown.asp and
http://www.c-sharpcorner.com/Code/2003/July/DropDownListBox.asp but I can't
seem to get it to work.
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:
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,
Tom