如何根据查询在gridview中显示文件夹中的图像 [英] How to display images from folder in gridview based on query
问题描述
嗨朋友们,
正在使用c#和sqlserver 2005处理asp.net项目。
在我的项目中,我有一个名为Images的文件夹。当基于CompanyCode的PageLoads时,这些图像应显示在gridview中。
假设我的公司代码名称为SecSyst,在gridview的此列旁边,它应显示此徽标公司从图像文件夹。
顺便说一下这是我的代码。
受保护 void Page_Load(对象发件人,EventArgs e)
{
if (!Page.IsPostBack)
{
Bindgridview();
}
}
< span class =code-keyword> private void Bindgridview()
{
SqlConnection con = new SqlConnection(_connString);
SqlCommand cmd = new SqlCommand( 选择CompanyCode,CompDesc,CompInfo,con);
SqlDataAdapter da = new SqlDataAdapter(cmd);
DataSet ds = new DataSet();
da.Fill(ds);
GVCompanies.DataSource = ds;
GVCompanies.DataBind();
}
请您告诉我如何根据gridview中的公司代码显示图像文件夹中的徽标。
所有公司徽标都在图片文件夹中。
请帮助,谢谢。
< blockquote>尝试以下链接: - 在gridview文件夹中显示图像asp.net
参考 this
试试这个.......
< asp:gridview id = GVCompanies runat = server backcolor = 白色 bordercolor = #999999 style = border:1px solid#c5c5c5; box-shadow:2px 2px 4px#c5c5c5 borderwidth = 1px cellpadding = 3 网格线 = 垂直 width = 100% xmlns:asp = #unknown >
< colu mns >
< < span class =code-leadattribute> asp:templatefield headertext = 图像 header style - width = 100px >
< ; itemtemplate >
< img src = Images / <% #Eval( CompanyCode)%> / >
< / itemtemplate >
< / asp:templatefield >
< / columns >
< / asp:gridview >
问候
AARIF SHAIKH
Hi friends,
am working on asp.net project using c# and sqlserver 2005.
In my project, i have folder with name Images. These images should be displayed in gridview when PageLoads based on CompanyCode.
Suppose If i have companycode with name SecSyst, Beside this column in gridview it should display the logo of this company from images folder.
By the way this is my code.
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
Bindgridview();
}
}
private void Bindgridview()
{
SqlConnection con = new SqlConnection(_connString);
SqlCommand cmd = new SqlCommand("Select CompanyCode,CompDesc,Compdetails from CompInfo", con);
SqlDataAdapter da = new SqlDataAdapter(cmd);
DataSet ds = new DataSet();
da.Fill(ds);
GVCompanies.DataSource = ds;
GVCompanies.DataBind();
}
Please can you show me how to display the logo from images folder based on companycode in gridview.
All the company logos are in images folder.
Please help, thanks.
Try the following link :- Display images in gridview from folder in asp.net
Refer this
Try This.......
<asp:gridview id="GVCompanies" runat="server" backcolor="White" bordercolor="#999999" style="border: 1px solid #c5c5c5; box-shadow: 2px 2px 4px #c5c5c5" borderwidth="1px" cellpadding="3" gridlines="Vertical" width="100%" xmlns:asp="#unknown"> <columns> <asp:templatefield headertext="Image" headerstyle-width="100px"> <itemtemplate> <img src="Images/<%#Eval("CompanyCode") %>" /> </itemtemplate> </asp:templatefield> </columns> </asp:gridview>
Regards
AARIF SHAIKH
这篇关于如何根据查询在gridview中显示文件夹中的图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!