本文介绍了图像不显示在datalist中..的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 29岁程序员,3月因学历无情被辞! 我在asp.net工作..这里将以datalist显示图像..但是数据显示者没有显示图像.. < asp:DataList ID = list runat = server OnItemCommand = list_ItemCommand RepeatColumns = 7 ShowFooter = true ShowHeader = true 宽度 = 98% > < ItemTemplate > < div align = center > < asp:Image ID = img runat = server BorderColor = white BorderWidth = 2 高度 = 100 ImageUrl =' <%# + Eval( image)%> ' 宽度 = 100px / > < asp:HiddenField ID = hf1 runat = server 值 =' <% #Eval( id)%> ' / > < br / > < span onclick = 返回确认('您确定要删除此图片吗?') > < asp:LinkBut​​ton ID = linkremove runat = server CommandName = 删除 文字 = 删除 > < / asp:LinkBut​​ton > < / span > < / div > < / ItemTemplate > < / asp:DataList > 我还需要如何删除datalist中的特定图像? 任何人都可以帮助我吗? ?在此先感谢:) 现在图像正常显示...但是datalist Item命令删除操作没有触发.. 受保护 void list_ItemCommand( object source,DataListCommandEventArgs e) { try { if (e.CommandName == Removes) { HiddenField id1 =(HiddenField)list.Items [e.Item.ItemIndex] .FindControl( hf1); if (dbo.deleterecords( image , id =' + id1.Value + ')== true ) { BindItemsList(); lbldel.Text = 图片已删除; } } } catch (例外情况) {异常E =前; } } 解决方案 您需要使用处理程序来显示数据库中的图像。以下是可以解释您需求的文章列表: ASP.NET中的图像处理 [ ^ ] 使用ASP保存和检索数据库中的图像。 NET [ ^ ] --Amit 为您的datalist添加标签并将其文本设置为''< %#Eval(image)%>''并检查它是否显示正确的路径?要删除图像,请使用datalist的itemcommand事件。 Am working in asp.net.. Here am going to display images in datalist.. But the datalist doesn''t show the image..<asp:DataList ID="list" runat="server" OnItemCommand="list_ItemCommand" RepeatColumns="7" ShowFooter="true" ShowHeader="true" Width="98%"> <ItemTemplate> <div align="center"> <asp:Image ID="img" runat="server" BorderColor="white" BorderWidth="2" Height="100" ImageUrl='<%# +Eval("image") %>' Width="100px" /> <asp:HiddenField ID="hf1" runat="server" Value='<%# Eval("id") %>' /> <br /> <span onclick="return confirm('Are you sure to Remove this Image?')"> <asp:LinkButton ID="linkremove" runat="server" CommandName="Removes" Text="Remove"></asp:LinkButton> </span> </div> </ItemTemplate> </asp:DataList>Also i need how to delete the particular image in datalist??Can any one help me?? Thanks in advance :)Now the image displayed properly... But the datalist Item command delete operation not firing..protected void list_ItemCommand(object source, DataListCommandEventArgs e) { try { if (e.CommandName == "Removes") { HiddenField id1 = (HiddenField)list.Items[e.Item.ItemIndex].FindControl("hf1"); if (dbo.deleterecords("image", "id='" + id1.Value + "'") == true) { BindItemsList(); lbldel.Text = "Image Deleted"; } } } catch (Exception ex) { Exception E = ex; } } 解决方案 You need to use handler to display the images from database. Here is the list of articles which will explain your need:Image Handling In ASP.NET[^]Save and Retrieve Images from the Database using ASP.NET[^]--AmitAdd a label to your datalist and set its text to ''<%# Eval("image") %>'' and check if it is displaying the correct path? To delete the image use datalist''s itemcommand event. 这篇关于图像不显示在datalist中..的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云!
09-05 13:50