使用Linq在DB的页面加载事件中显示图像 [英] Display Image at the Page load event from DB Using Linq
本文介绍了使用Linq在DB的页面加载事件中显示图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想在页面加载事件触发时向我的asp页面显示数据库中存在的图像.我想在列表视图中显示图像,并且我想使用linq查询来执行它.我该怎么做,请回复
谢谢.
Hi,
I want to display images that are present in the db to my asp page as page load event fires.I want to display images in the list-view,and I want to use linq queries to perform it.How Can I do It please Reply
Thank You.
推荐答案
我会写一个从PageLoad事件处理程序调用的方法.此方法将查询数据库,检索必要的数据,然后将其绑定到适当的控件.
I would write a method that''s called from the PageLoad event handler. This method would query the database, retrive the necessary data, and then bind it to the appropriate control.
public void GetImage()
{
DataClasses2DataContext db=new DataClasses2DataContext();
CheckInCheckOut1 chkInOut1 = new CheckInCheckOut1();
var img = from c in db.CheckInCheckOut1s
select new
{
Name = c.Name,
ID = c.ID,
Image = c.ImageUrl,
};
//ListView1.DataSource = img;
lst1.DataBind();
这篇关于使用Linq在DB的页面加载事件中显示图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文