• How to show data on datagridview with entity framework?

    Arden Member

    How to show data on datagridview with entity framework?

    can anyone give me a lead on how this will work
    i was looking for some tutorials online and i apply them on my project but it not work properly

    in this video tutorial

    
    

    he just put it like this

    GridView.DataSource = db.Personsmain;
    GridView.DataBind();
    
    ______________
    
    in my coding..
    projectentities ent = new projectentities();
    
    DataGridView.DataSource = ent.teacher_table;
    DataGridView.DataBind();
    

    i’m getting an error in “DataBind();”

    is there any simpler way to show data to datagridview? i’m using windows form application C# unlike him using webform. Would it be that differences cause that problem?

  • Adelaid Member

    As I have no idea what the error is stating and I have no idea what the rest of the code is, I know System.Windows.Forms.DataGridViewdoesn’t have a method DataBind().

    The databinding happens automatically without calling the method (this method is only used in webforms’ version: GridView)

    So, try without the method, just add the datasource and run the code:

    projectentities ent = new projectentities();
    DataGridView.DataSource = ent.teacher_table;
    
Viewing 1 reply thread
  • You must be logged in to reply to this topic.
en_USEnglish