Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7523469
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T02:48:43+00:00 2026-05-30T02:48:43+00:00

Sorry for troubling. Im trying to display the selected fields in a asp.net gridview.

  • 0

Sorry for troubling. Im trying to display the selected fields in a asp.net gridview. i can display everything except the “product_img” where i should display the relevant picture in the gridview.

The problem is in gridview when i attached image url of image control to code-'<%#"InsertProd.aspx.cs?path" %>' is not working as it’s giving me null images/broken image link.

is my method of binding the path upon dr.read to the imageURL in gridview wrong??
i have edited my code behind page as below and design aspx page as bottom.

the code for designer page is located below underneath,upon scroll down. thank you.

    protected void gvShowInsert_SelectedIndexChanged(object sender, EventArgs e)
    {
        SqlCommand cmd = new SqlCommand("SELECT product_cakeName, product_price,      
        product_qty,product_desc,product_img FROM Tbl_Products", conn);

        conn.Open();

        SqlDataReader dr;
        dr = cmd.ExecuteReader();
        if(dr.Read())
        {
           //Context.Response.BinaryWrite((byte[])dr[dr.GetOrdinal("product_img")]);


          byte[] path = (byte[])dr["product_img"]; //read the path of image

        }//imageControl.ImageUrl = path; //set the path to image control


        gvShowInsert.DataSource = dr;
        gvShowInsert.DataBind();
        dr.Close();
        conn.Close();
    }

this is my design aspx:

<Columns>
   <asp:TemplateField HeaderText="cake-name">
       <ItemTemplate>
            <asp:Label ID="lblHeaderName"   
            runat="server"Text='<%#Eval("product_cakeName") %>'></asp:Label>    
       </ItemTemplate>
  </asp:TemplateField>
 <asp:TemplateField HeaderText="price">
   <ItemTemplate>
   <asp:Label ID="lblHeaderPrice" runat="server" Text='<%#Eval("product_price")  
           %>'></asp:Label>    
    </ItemTemplate>
 </asp:TemplateField>
 <asp:TemplateField HeaderText="qty">
 <ItemTemplate>
 <asp:Label ID="lblHeaderQty" runat="server" Text='<%#Eval("product_qty") %>'></asp:Label>    
 </ItemTemplate>
 </asp:TemplateField>
 <asp:TemplateField HeaderText="desc">
 <ItemTemplate>
 <asp:Label ID="lblHeaderDesc" runat="server" Text='<%#Eval("product_desc") %>'>
 </asp:Label>    
 </ItemTemplate>
 </asp:TemplateField>
 <asp:TemplateField HeaderText="img">
 <ItemTemplate>
<asp:Image ID="imageControl" runat="server" ImageUrl='<%#"InsertProd.aspx.cs?path" %>' >
</asp:Image>    
</ItemTemplate>
</asp:TemplateField>
</Columns>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T02:48:44+00:00Added an answer on May 30, 2026 at 2:48 am

    If you have the image path, or image filename, stored in the database, why not just assign it like you do the values for the other controls? Like this:

    If your database stores the entire path, do this:

    <asp:Image ID="imageControl" runat="server" ImageUrl='<%# Eval("product_img") %>'></asp:Image>
    

    If your database only has the filename, do this:

    <asp:Image ID="imageControl" runat="server" ImageUrl='<%# String.Format("~/path/to/image/" + Eval("product_img")) %>'></asp:Image>
    

    Good Luck!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Sorry, I'm sure this is simple but I'm tired and can't figure it out.
Sorry for the unhelpful title, but hopefully I can explain this well enough. Lets
sorry for my english. i use classic asp and try open recordset with following
Sorry to bother you all here but I am still trying to understand more
Sorry if this has been addressed. I just can't get it to work. I
Sorry for the basic question - I'm a .NET developer and don't have much
Sorry if the title is poorly descriptive, but I can't do better right now
Sorry for the simple question, but I'm trying to find an elegant way to
Sorry if this doesn't make any sence, but I'm trying my best to understand
Sorry, I can tell I don't entirely know what I'm talking about. For example,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.