fillaUrinee
New Member
I am using a gridview which is having dropdownlist in edittemplate field. There are 3 list items in dropdown : Red,Amber,Green. Instead of displaying text in listitems, I want to show the colors, for the same I am using dropdownlist's onLoad event, however this event is not able to recognize the dropdownlist. Dropdownlist Designer code :\[code\]<asp:TemplateField HeaderText="Color"><EditItemTemplate> <aspropDownList ID="ddlcolor" runat="server" AppendDataBoundItems="true" DataTextField="COLOR" DataValueField ="COLOR" OnLoad="DDLColor_Load"> <asp:ListItem Value="http://stackoverflow.com/questions/14577737/-1">- Select Color -</asp:ListItem> <asp:ListItem Value="http://stackoverflow.com/questions/14577737/0">Amber</asp:ListItem> <asp:ListItem Value="http://stackoverflow.com/questions/14577737/1">Green</asp:ListItem> <asp:ListItem Value="http://stackoverflow.com/questions/14577737/2">Red</asp:ListItem> </aspropDownList></EditItemTemplate></asp:TemplateField>\[/code\]Dropdownlist onLoad Event in codebehing :\[code\] protected void DDLColor_Load(object sender, EventArgs e){ for (int i = 0; i < ddlcolor.Items.Count; i++) { ddlcolr.Items.Attributes.Add("style", "background-color:" + ddlcolor.Items.Text); }} \[/code\]However, it shows that the dropdownlist ddlcolor does not exists in current context.Do I need to find this control in gridview ? Please suggest.