locked
GridControl not displaying RRS feed

  • Question

  • Hi!

    I am practicing ADO.net Entity framework. But I am unable to populate data on my GridControl(Devexpress). The following is my code.

    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Linq;
    using System.Text;
    using System.Windows.Forms;

    namespace ConsoleApplication1
    {
        public partial class NewCustomerForm : Form
        {
            AFApp_H1Entities entities = new AFApp_H1Entities();
            public NewCustomerForm()
            {

                InitializeComponent();
            }

            private void NewCustomerForm_Load(object sender, EventArgs e)
            {
                var query = from c in entities.Customers
                                where c.ZIP == "77080"
                                select c.CustomerName;

                    this.Controls.Add(gridControl1);
                    gridControl1.DataSource = query;

            }
        }
    }

    but when I run the same query in a console application and not a form it gives all the rows with zip code 77080 why is it not populating on the grid?

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.Windows.Forms;

    namespace ConsoleApplication1
    {
        class Program
        {
            public static void Main()
            {

                AFApp_H1Entities entities = new AFApp_H1Entities();
                var query = from c in entities.Customers
                            where c.ZIP == "77080"
                            select c.CustomerName;

                foreach (var item in query)
                {
                    Console.WriteLine(item);
                }


                Application.Run(new NewCustomerForm());
            }
        }
    }

    Thanks!


    • Edited by IrtizaRizvi Thursday, March 29, 2012 5:22 PM
    Thursday, March 29, 2012 5:20 PM

Answers

  • Hi IrtizaRizvi,

    Welcome to MSDN Forum.

    Based on this issue, I suggest you to post the question in DevExpress Forums, there are more related experts, I think you can get more help.

    Best Regards


    Allen Li [MSFT]
    MSDN Community Support | Feedback to us

    • Marked as answer by Allen_MSDN Thursday, April 5, 2012 2:13 AM
    Monday, April 2, 2012 2:16 AM

All replies

  • Hello, I never use a Devexpress grid control, but, did you try gridcontrol1.DataBind() after assign the gridcontrol1.DataSource?

    And... are you sure that grid control supports object collections as a data source?

    Hope this helps,

    Miguel.

    Thursday, March 29, 2012 5:33 PM
  • Hi IrtizaRizvi,

    Welcome to MSDN Forum.

    Based on this issue, I suggest you to post the question in DevExpress Forums, there are more related experts, I think you can get more help.

    Best Regards


    Allen Li [MSFT]
    MSDN Community Support | Feedback to us

    • Marked as answer by Allen_MSDN Thursday, April 5, 2012 2:13 AM
    Monday, April 2, 2012 2:16 AM