我想根据用户ID在网格视图中显示图像。问题是我的图像存储在另一个驱动器中,而不是存储在网站文件夹中。即使我找到路径,也不允许我显示图像。在GridView中从DB显示图像其中PAth在其他驱动器中
根据这个链接How to display image which is stored in local drive?
在该职位的回答表明其创建通过根据ID查询字符串或东西另一个页面。
我是新来的,不知道如何使用查询字符串。
我写了下面的代码: -
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="false">
<Columns>
<asp:BoundField DataField="User_ID" HeaderText="User_ID" />
<asp:ImageField DataImageUrlField="Photo_File_Path" HeaderText="Photo_File_Path">
</asp:ImageField>
</Columns>
</asp:GridView>
SqlConnection con = new SqlConnection(CS);
SqlCommand cmd = new SqlCommand("SELECT User_ID, Photo_File_Path FROM User_M", con);
con.Open();
SqlDataReader rdr = cmd.ExecuteReader();
GridView1.DataSource = rdr;
GridView1.DataBind();
con.Close();
我如何得到我的代码的查询字符串工作或是否有任何其他方式我可以显示图片。
谢谢。
,但它仍然无法正常工作。 – user2211486
好吧,那就是我所担心的 - 所以希望别人能告诉我们如何在这些现代时代做到这一点:) –