0

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 Answers 2

3

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();

        }
Sign up to request clarification or add additional context in comments.

10 Comments

@Nirmal: Where this DataClasses1DataContext is coming from?
DataClasses1DataContext is the DataContext Class. It get automatically generated when we have added a LINQ to SQL. I hope you are using LINQ to SQL.
I added a DBML file in my solution. Name is: MyLinqToSql.dbml
Then you can try with MyLinqToSQLDataContext instead of DataClasses1DataContext
And I also mapped the tables and their association. Now I am in the Page2.aspx
|
0

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();

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.