c# .net Adsense ADO.NET Linq Viruses/security asp.net MVC JQuery Angular-js Node-js SEO Java C++ SQL API Networking vb.net .Net Css JavaScript Generics c#.Net entity framework HTML Website host Website Construction Guide HTTP tutorial W3C tutorial Web Services JSON Psychology Ionic framework Angular ReactJS Python Computer Android
c# .net

How to load ChartTypes in DropDownList using asp.net?

| | ASP-NET , chart

In this article we will discuss, to load ChartTypes in DropDownList using asp.net. We will get list of chart name by using SeriesChartType and bind to DropDownList on PageLoad.

Flowchart.aspx:

<asp:DropDownList ID="cboChartType" AutoPostBack="true" runat="server"
                    OnSelectedIndexChanged="cboChartType_SelectedIndexChanged">
                </asp:DropDownList>

Flowchart.aspx.cs:

protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                GetChartTypes();
            }
        }

private void GetChartTypes()
        {
            foreach (int chartType in Enum.GetValues(typeof(SeriesChartType)))
            {
                ListItem li = new ListItem(Enum.GetName(typeof(SeriesChartType),
                    chartType), chartType.ToString());
                ChartType.Items.Add(li);
            }
        }

Output: