sandhiya sandhiya - 8 days ago 4x
ASP.NET (C#) Question

How to add listitems to dropdown list in devexpress in design mode

i have old project which is in and now i am changing that project to devexpress so i want to add list items to dropdownlist in devexpress

<asp:DropDownList ID="ddlErrorType" runat="server" AppendDataBoundItems="True">
<asp:ListItem Text="DB Error"></asp:ListItem>
<asp:ListItem Text="UI Error"></asp:ListItem>
<asp:ListItem Text="Logical"></asp:ListItem>
<asp:ListItem Text="Numeric"></asp:ListItem>
<asp:ListItem Text="Validation"></asp:ListItem>


You can use the below code to do the above in the code-behind:

protected void Page_Load(object sender, EventArgs e)
    //Bind method to the ComboBox
    DropDownList1.DataSource = GetDataSource();

private DataTable GetDataSource()
    //DataTable defined
    var dtSource = new DataTable();
    dtSource.Columns.Add("Id", typeof(int));
    dtSource.Columns.Add("FirstName", typeof(string));

    //Fill rows
    dtSource.Rows.Add(1, "Item One");
    dtSource.Rows.Add(2, "Item Two");
    dtSource.Rows.Add(3, "Item Three");
    dtSource.Rows.Add(4, "Item Four");

    return dtSource;

You can do it in the design mode, see this - Add Item To DevExpress ComboBox