简体   繁体   English

使用EntityDataSource和QueryString填充GridView

[英]Populating GridView using EntityDataSource and QueryString

I am new to EntityFrameWork so bear with me here. 我是EntityFrameWork的新手,请在这里与我联系。 I have a webpage (page1.apsx) n page2.aspx. 我有一个网页(page1.apsx)n page2.aspx。

Page1.aspx is showing gridview of following items: Page1.aspx显示以下项目的gridview:

EntityID 实体ID
Name 名称
Description 描述

Whenever user is selecting some Entity then I am passing this EntityID to Page2.aspx. 每当用户选择某个实体时,我都会将此EntityID传递给Page2.aspx。 In Page2 I am having EntityDataSource and GridView. 在Page2中,我拥有EntityDataSource和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? 您如何在EntityDataSource中处理此问题并在GridView中填充它?

Thank you! 谢谢!

let's consider the Query String as http://www.xyz.com/Page1.aspx?EntityID=1 让我们将查询字符串视为http://www.xyz.com/Page1.aspx?EntityID=1

In the Page2 在第2页

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

        }

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM