Click here to Skip to main content
15,920,217 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
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.


C#
protected void Page_Load(object sender, EventArgs e)
   {
      
       if (!Page.IsPostBack)
       {
           Bindgridview();
       }
   }



C#
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.
Posted
Updated 3-Feb-14 0:32am
v2

 
Share this answer
 
Refer this
 
Share this answer
 
Try This.......

ASP.NET
<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
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900