首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >使用EntityDataSource和QueryString填充EntityDataSource

使用EntityDataSource和QueryString填充EntityDataSource
EN

Stack Overflow用户
提问于 2011-03-23 13:36:03
回答 2查看 4.1K关注 0票数 0

我是EntityFrameWork的新手,所以请容忍我在这里。我有一个网页(page1.apsx) n page2.aspx。

Page1.aspx显示以下项目的网格视图:

EntityID

名字

描述

每当用户选择某个实体时,我都会将这个EntityID传递给Page2.aspx。在Page2,我有EntityDataSource和GridView。此外,需要填充的值来自此页面中的不同表。如何在EntityDataSource中处理这个问题,并在GridView中填充它?

谢谢!

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2011-03-23 13:41:15

让我们把查询字符串看作是http://www.xyz.com/Page1.aspx?EntityID=1

在Page2中

代码语言:javascript
复制
 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();

        }
票数 3
EN

Stack Overflow用户

发布于 2011-03-24 05:50:37

试着用这个。

代码语言:javascript
复制
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();
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/5406043

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档