我是EntityFrameWork的新手,所以请容忍我在这里。我有一个网页(page1.apsx) n page2.aspx。
Page1.aspx显示以下项目的网格视图:
EntityID
名字
描述
每当用户选择某个实体时,我都会将这个EntityID传递给Page2.aspx。在Page2,我有EntityDataSource和GridView。此外,需要填充的值来自此页面中的不同表。如何在EntityDataSource中处理这个问题,并在GridView中填充它?
谢谢!
发布于 2011-03-23 13:41:15
让我们把查询字符串看作是http://www.xyz.com/Page1.aspx?EntityID=1
在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();
}发布于 2011-03-24 05:50:37
试着用这个。
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();https://stackoverflow.com/questions/5406043
复制相似问题