0
votes

I am new to EntityFrameWork so bear with me here. I have a webpage (page1.apsx) n page2.aspx.

Page1.aspx is showing gridview of following items:

EntityID
Name
Description

Whenever user is selecting some Entity then I am passing this EntityID to Page2.aspx. In Page2 I am having EntityDataSource and GridView. Also, the value needs to be populated is from different tables in this page. How you deal with this in EntityDataSource and populating it in GridView?

Thank you!

2

2 Answers

3
votes

let's consider the Query String as http://www.xyz.com/Page1.aspx?EntityID=1

In the Page2

 protected void Page_Load(object sender, EventArgs e)
        {
            DataClasses1DataContext db = new DataClasses1DataContext();
            var te = from p in db.table
                     where p.entityid=Request.Querystring["EntityID"]
                     select p;
            GridView1.DataSource = te;
            GridView1.DataBind();

        }
0
votes

Try Using this.

OISLinqtoSQLDataContext db = new OISLinqtoSQLDataContext();
        var tr = from r in db.Users
                 join s in db.Entities on r.UserID equals s.ID
                 where s.ID = Convert.ToInt32(Request.QueryString["EntityID"])
                 select new
                 {
                     //To Show Items in GridView!
                 };

    GridView1.DataSource = tr;
    GridView1.DataBind();