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. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Fill dropdownlist that is inside grid cell with another datasource

Thread ID:

Created:

Updated:

Platform:

Replies:

118480 Mar 11,2015 07:59 PM UTC Mar 16,2015 02:23 PM UTC ASP.NET Web Forms 3
loading
Tags: Grid
Artur
Asked On March 11, 2015 07:59 PM UTC

Hi, I have a grid and that has some EditType="DropDown" columns.

I would like to fill these dropdowns with data from another datasource besides 
the grid one. Any clue?



Balaji Marimuthu [Syncfusion]
Replied On March 12, 2015 12:37 PM UTC

Hi Artur,

Thanks for using Syncfusion Products.

We have achieved your requirement by using the DataSource property in Grid columns. Please find the sample and the code snippet.

Sample: 118480-dropdown.zip

[Default]

  <ej:Grid ID="OrdersGrid" runat="server" AllowPaging="True" >

          

            <Columns>

                <ej:Column Field="OrderID" HeaderText="Order ID" IsPrimaryKey="true" TextAlign="Right" Width="90"/>

                <ej:Column Field="CustomerID" HeaderText="Customer ID" Width="90" EditType="Dropdown" />

               

              . . . . . . .

           </Columns>

           

        </ej:Grid>

[Default.aspx]

        List<Customer> customers = new List<Customer>();

        protected void Page_Load(object sender, EventArgs e)

        {

            customers.Add(new Customer() { text = "Andreas", value = "Andreas" });

            customers.Add(new Customer() { text = "Frank" ,  value = "Frank" });

            customers.Add(new Customer() { text = "Willi" ,  value = "Willi" });

            customers.Add(new Customer() { text = "Horst" ,  value = "Horst" });

            customers.Add(new Customer() { text = "Manfred",  value = "Manfred" });

            BindDataSource();            

        }

        private void BindDataSource()

        {

            

            . . . . . . .           

           this.OrdersGrid.DataSource = order;

            var index = this.OrdersGrid.Columns.FindIndex(col => col.Field == "CustomerID");

            this.OrdersGrid.Columns.ElementAt(index).DataSource = customers;

       

            this.OrdersGrid.DataBind();

        }

        [Serializable]

        public class Customer

        {

            public Customer()

            {

            }

            public Customer(string text, string value)

            {

                this.text = text;

                this.value = value;

            }

            public string text { get; set; }

            public string value { get; set; }

        }

    }

By using the DataSource property in Grid columns, we can bind the datasource to the columns in editmode.

Please let us know If you have any queries.

Regards,

Balaji Marimuthu



Artur
Replied On March 13, 2015 01:19 PM UTC

This was very very useful! Thanks!

But I'd like to say that I found another way to do it using 
a custom template with an independent dropdown ;)

Thanks anyway


Balaji Marimuthu [Syncfusion]
Replied On March 16, 2015 02:23 PM UTC

Hi Artur,

Thank you for the update.

Please let us know if you need any further assistance.

Thanks,

Balaji Marimuthu

CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

;