How To Bind DropdownList with all system color in ASP.NET

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="AllColors.aspx.cs"
 Inherits="AllColors" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
<html xmlns="">
<head runat="server">
  <title>Untitled Page</title>
  <form id="form1" runat="server">
          <asp:DropDownList ID="ddlColor" runat="Server">
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Drawing;

public partial class AllColors : System.Web.UI.Page
   protected void Page_Load(object sender, EventArgs e)
       ArrayList arrlist = new ArrayList();
       KnownColor enumColor = new KnownColor();
       Array Colors = Enum.GetValues(enumColor.GetType());
       foreach (object clr in Colors)
           if (!Color.FromKnownColor((KnownColor)clr).IsSystemColor)
       ddlColor.DataSource = arrlist;

Post a Comment

Please do not post any spam link in the comment box😊

Previous Post Next Post

Blog ads