本文介绍了如何在GridView中显示图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个不显示该图像的图像.我已将图像存储在名为"UserImages"的文件夹中
设计代码:该代码位于GridView内部

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

<asp:Image ID="ImageLogo" runat="server" Width="75" Height="80" Text='<%#Eval("User_Image") %>' ToolTip='<%#Eval("User_Image") %>' />



背后的代码



Code Behind

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

           }
       }

推荐答案


<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>









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();
        }


这篇关于如何在GridView中显示图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-02 17:20