We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

Binding a String[] to DropDown in Grid?

Is it possible to bind just a simple String[] as a datasource for a Dropdown?

                string[] per= { "One", "Two", "Three" };

                var index = this.grdBudget.Columns.FindIndex(col => col.Field == "Period");   //dropdown control
                this.grdBudget.Columns.ElementAt(index).DataSource = per;

                grdBudget.DataSource = new BudgetEntities().Requests.ToList();

PS in this short example I'm assigning 'per' statically but in my application I'll need to assign it dynamically, hence cannot just put the choices in the control def in xml.


1 Reply

PK Prasanna Kumar Viswanathan Syncfusion Team September 15, 2016 03:08 PM UTC

Hi Michael, 
Thanks for contacting Syncfusion support. 
To bind an array of string as a dataSource for dropdown, use the editTemplate property of columns. Use editTemplate property we render the dropdown for particular column and bind the array of string as a datasource for the column. 
Find the code example and sample: 
<ej:Grid ID="OrdersGrid" runat="server" AllowPaging="True" > 
            <EditSettings AllowEditing="True" AllowAdding="True" AllowDeleting="True"></EditSettings> 
            <ToolbarSettings ShowToolbar="True" ToolbarItems="add,edit,delete,update,cancel"></ToolbarSettings> 
<script type="text/javascript"> 
        function create() { 
            return $("<input>"); 
        function write(args) { 
            var obj = $('#<%= OrdersGrid.ClientID %>').ejGrid('instance'); 
            var numbers = ["One", "Two", "Three"]; 
                width: "100%", 
                dataSource: numbers, 
                value: args.rowdata !== undefined ? args.rowdata["CustomerID"] : "" 
        function read(args) { 
            return args.ejDropDownList("getValue"); 
Prasanna Kumar N.S.V 

Live Chat Icon For mobile
Up arrow icon