Hi
Here is some few steps to do this task
Note: I have tested this code with asp.net 3.5 sp1, In asp.net 4.0 also process is same.
Step1: Go to solution Explore, then right click then add new item like this
Step2: Click on next like this
Step3: Select the Exact database and click on next like this
Step4: Select your table name like this
Step5: Then you will get Model.edmx file like this
Step6:Take one gridview asp.net control in default page and write the code in code behind page like this
protected void Page_Load(object sender, EventArgs e)
{
fillGrid();
}//This code is used for fetch data from database
protected void fillGrid()
{
using (TestModel.TestEntities TE = new TestModel.TestEntities())
{
var query = from m in TE.tblEmp
orderby m.Id descending
select m;
Gridview1.DataSource = query;
Gridview1.DataBind();
}
}
how to fill data in gridview by entity framework in asp.net
how to fill data in gridview by entity framework in asp.net important problem please help me
sir i have problem
how to insert and save data in table iby entity framework in asp.net
please tell me the solution
thaks and regards
Hitesh
Hi
Please check this artical
https://chandradev819.wordpress.com/2011/05/13/how-to-do-insertupdatedelete-using-entity-framework-in-asp-net/
sir,
and one think is most important fill data in gridview by your method and successfully implemented but please tell me solution if multiple tables so how to fill data in gridview on same page
please help me
thanks and regards
Hitesh
Hi
Please give me some time. I will write artical on this topic.
Regards
Chandradev
thanks a lot sir
you give me a response
thanks sir
thanks and regards hitesh
Hi,
How can we insert the data available in gridview(newly added row/rows) to the database table.
Hi
Like this you add data in database
using (TestModel.TestEntities TE = new TestModel.TestEntities())
{
TestModel.tblEmp objEmp = new TestModel.tblEmp();
objEmp.EmpName = txtEmpName.Text;
objEmp.EmpSal = txtEmpSal.Text;
TE.AddTotblEmp(objEmp);
TE.SaveChanges();
lblmsg.Text = “Data has been inserted sucessfully”;
txtEmpName.Text = “”;
txtEmpSal.Text = “”;
}
}
thank u sir this is helpful for me
You are welcome.