I have a page where I create div controls dynamiclly and number them automaticlly.
subCell = new TableCell();
subCell.Controls.Add(new LiteralControl(
"<div id=\"picker" + Index.ToString() + "\" runat=\"server\"
class=\"colorSelector\"><div style=\"background-color: #000000;\">Text
</div></div>"));
subRow.Cells.Add(subCell);
subTb.Rows.Add(subRow);
Later in the code I want to get the background-color value like so:
HtmlGenericControl div;
div = (HtmlGenericControl)Page.FindControl("picker" + e.CommandArgument.ToString());
string colorCode = div.Style["background-color"].ToString();
after these line of code I get a null object ref error. div is null. I have tried HtmlControl and LiteralControl as the object type and that does not help either.
Thank you!