Click here to Skip to main content
15,901,373 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i have an image that does not display the image. i have stored the image in a folder called "UserImages"
Design Code : The code is inside the GridView
C#
<asp:Image ID="ImageLogo" runat="server" Width="75" Height="80" Text='<%#Eval("User_Image") %>' ToolTip='<%#Eval("User_Image") %>' />


Code Behind
C#
protected void DataList1_RowDataBound(object sender, GridViewRowEventArgs e)
       {
           if (e.Row.RowType == DataControlRowType.DataRow)
           {
      (e.Row.FindControl("ImageLogo") as Image).ImageUrl = "/UserImages/" + e.Row;

           }
       }
Posted
Comments
Kundan Singh Chouhan 3-Aug-14 1:02am    
What is the exact path of your image?

"/UserImages/" + e.Row; seems incorrect here.

your image path is wrong it is like that "~/UserImages/" +e.r=Row;
 
Share this answer
 
Image upload code like this..


ASP.NET
<asp:gridview id="GridView1" runat="server" autogeneratecolumns="False" xmlns:asp="#unknown">
            Height="16px" Width="100px">
        <columns>
        <asp:imagefield headertext="Profile Picture" dataimageurlfield="Path" />
        </columns>
        </asp:gridview>




C#
public void fill()
        {
            string name = Application["Name"].ToString();
            SqlDataAdapter da = new SqlDataAdapter("select Path from tbl_imageupload where UserName ='" + name + "'", con);
            DataTable dt1 = new DataTable();
            da.Fill(dt1);
            GridView1.DataSource = dt1;
            GridView1.DataBind();
        }
 
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