检索图像路径并使用中继器显示时出现问题 [英] problem in retriving image path and show it using repeater

查看:83
本文介绍了检索图像路径并使用中继器显示时出现问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用server.mappath将图像路径存储在数据库中,该路径被存储.我想从转发器中新存储的路径中显示图像.图片未显示.我不知道问题
在后面的代码中

"Upload succesfully";
            con.Open();
            string command1 = "insert into gallery (galleryimage) values (''" + path + "'')";
            SqlCommand cmd1 = new SqlCommand(command1, con);
            cmd1.ExecuteNonQuery();
            con.Close();
        }
        catch (Exception ex)
        {
            Label3.Text="error"+ex.Message.ToString();
        }
    }
}
public void bind2()
{
    con.Open();
    SqlDataAdapter da1 = new SqlDataAdapter("select galleryimage from gallery", con);
    DataTable dt1 = new DataTable();
    da1.Fill(dt1);
    Rp1.DataSource = dt1;
    Rp1.DataBind();
}
protected void Viewfile_Click(object sender, EventArgs e)
{
    bind2();
}



在源代码中

<asp:FileUpload ID="Fileup" runat="server" />
         <br />
         <br />
         <asp:Button ID="BtnSave" Text="Upload" runat="server" onclick="BtnSave_Click" />
         &nbsp;&nbsp;&nbsp;
             <asp:Label ID="Label3" runat="server"></asp:Label>
             <br />
         <br /><br />
         <asp:Repeater ID="Rp1" runat="server">
         <ItemTemplate>
         <table>
         <tr>
         <td width="100%" height="100%">
         <img src=''<%#Eval("galleryimage") %>'' height="100%" width="100%" />
         </td>
         </tr>
         </table>
         </ItemTemplate>
             </asp:Repeater>



我在数据库中发现错误,它像D:\image\
那样存储路径 但是我们必须得到像D:/image
这样的路径
给我打电话解决方案

解决方案

/* Your Need to contact Your Image Location Folder path and  Image Name retrieve from the DataBase in the f0llowing way. */

<asp:Image ID="ImageButton2" ImageUrl=''<%# String.Concat("Image/", Eval("ProductImage")) %>'' Width="50%" Height="30%" runat="server" />


i stored the image path in database using server.mappath the path is stored. i want to show the image from newly stored path in repeater. the image was not shown. i dont know the problem the
in code behind

"Upload succesfully";
            con.Open();
            string command1 = "insert into gallery (galleryimage) values (''" + path + "'')";
            SqlCommand cmd1 = new SqlCommand(command1, con);
            cmd1.ExecuteNonQuery();
            con.Close();
        }
        catch (Exception ex)
        {
            Label3.Text="error"+ex.Message.ToString();
        }
    }
}
public void bind2()
{
    con.Open();
    SqlDataAdapter da1 = new SqlDataAdapter("select galleryimage from gallery", con);
    DataTable dt1 = new DataTable();
    da1.Fill(dt1);
    Rp1.DataSource = dt1;
    Rp1.DataBind();
}
protected void Viewfile_Click(object sender, EventArgs e)
{
    bind2();
}



in source code

<asp:FileUpload ID="Fileup" runat="server" />
         <br />
         <br />
         <asp:Button ID="BtnSave" Text="Upload" runat="server" onclick="BtnSave_Click" />
         &nbsp;&nbsp;&nbsp;
             <asp:Label ID="Label3" runat="server"></asp:Label>
             <br />
         <br /><br />
         <asp:Repeater ID="Rp1" runat="server">
         <ItemTemplate>
         <table>
         <tr>
         <td width="100%" height="100%">
         <img src=''<%#Eval("galleryimage") %>'' height="100%" width="100%" />
         </td>
         </tr>
         </table>
         </ItemTemplate>
             </asp:Repeater>



i found mistake in database it store the path as like D:\image\
but we have to get the path like D:/image

tel me the solution

解决方案

/* Your Need to contact Your Image Location Folder path and  Image Name retrieve from the DataBase in the f0llowing way. */

<asp:Image ID="ImageButton2" ImageUrl=''<%# String.Concat("Image/", Eval("ProductImage")) %>'' Width="50%" Height="30%" runat="server" />


这篇关于检索图像路径并使用中继器显示时出现问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆