title: How to save and retrieve data from database using Entity Model
body: <pre><code>protected void btnsubmit_Click(object sender, EventArgs e)
  {
      dbdataEntities1 dbsdemo = new dbdataEntities1();
      string fname = txtname.Text;
      string lname = txtlastname.Text;
      string email = txtemail.Text;
      string gender = Rbgender.SelectedValue;
      string phoneno = txtphno.Text;
      string role = DropDownList1.SelectedValue;
      string filename = System.IO.Path.GetFileName(Fupload.FileName);
      Fupload.SaveAs(Server.MapPath("Uploads/") + filename);
      tbldata tab = new tbldata();
      tab.filename = filename;
      tab.firstname = fname;
      tab.lastname= lname;
      tab.email = email;
      tab.gender = gender;
      tab.phoneno = Convert.ToInt32(phoneno);
      tab.role = role;
      dbsdemo.tbldatas.Add(tab);
      dbsdemo.SaveChanges();
  }
  
  //View.aspx.cs
  
  protected void Page_Load(object sender, EventArgs e)
  {
      SqlConnection con = new SqlConnection(@"Data Source=(LocalDB)\MSSQLLocalDB;AttachDbFilename=C:\Users\Napster\documents\visual studio 2015\Projects\WebApplication1\WebApplication1\App_Data\dbdata.mdf;Integrated Security=True;MultipleActiveResultSets=True;Application Name=EntityFramework");
      SqlCommand cmd = new SqlCommand("Select * from tbldata",con);
      SqlDataAdapter adapter = new SqlDataAdapter(cmd);
      DataSet ds = new DataSet();
      adapter.Fill(ds);
      GridView1.DataSource = ds;
      //dbdataEntities1 dbsdemo = new dbdataEntities1();
      // DataSet query = new DataSet();
      // query=    (from tb in dbsdemo.tbldatas select tb).ToList();
      //GridView1.DataSource = dbsdemo.tbldatas.ToList();
      GridView1.DataBind();
  }
  
  //view.ASPX
  &lt;asp:ImageField DataImageUrlField="filename" DataImageUrlFormatString="~\Uploads\{0}" HeaderText="Photo" ControlStyle-Height="100" ControlStyle-Width="100" &gt;
      &lt;ControlStyle Height="100px" Width="100px"&gt;&lt;/ControlStyle&gt;
  &lt;/asp:ImageField&gt;
      &lt;asp:HyperLinkField DataNavigateUrlFields="id" DataNavigateUrlFormatString="update.aspx?id={0}" DataTextField="id" DataTextFormatString="Edit" HeaderText="Edit" Text="Edit" /&gt;
  &lt;/Columns&gt;
  </code></pre>