zoukankan      html  css  js  c++  java
  • GridView中添加图片显示

    实现功能:gridview中添加图片显示

    .aspx文件代码
    <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ConnectionStrings:ConnectionString%>"
                SelectCommand
    =" select * from FriendsLink order by ID desc" DeleteCommand="delete from FriendsLink where ID=@ID" UpdateCommand="update FriendsLink set LinkName=@LinkName,LinkAdress=@LinkAdress,LinkPicPath=@LinkPicPath where ID=@ID">
            
    </asp:SqlDataSource>
            
    <asp:GridView ID="GridView1" runat="server" AllowPaging="True" AllowSorting="True"
                AutoGenerateColumns
    ="False" DataSourceID="SqlDataSource1" ForeColor="#333333"
                BorderWidth
    ="1px" RowStyle-HorizontalAlign="Center" CellPadding="3" GridLines="Vertical"
                Width
    ="760px" DataKeyNames="ID" PageSize="15">
                
    <Columns>
                    
    <asp:HyperLinkField DataNavigateUrlFields="ID" DataNavigateUrlFormatString="./showLink.aspx?ID={0}"
                        DataTextField
    ="LinkName" HeaderText="详细信息" />
                        
                    
    <asp:ImageField DataImageUrlField="LinkPicPath" DataImageUrlFormatString="{0}" HeaderText="Logo">
                    
    </asp:ImageField>
                    
    <asp:BoundField DataField="LinkName" HeaderText="链接名称" SortExpression="LinkName" />
                    
    <asp:BoundField DataField="LinkAdress" HeaderText="链接地址" SortExpression="LinkAdress" />
                    
    <asp:CommandField ShowEditButton="true" HeaderText="编辑" />
                    
    <asp:CommandField ShowDeleteButton="True" HeaderText="删除" />
                
    </Columns>
                
    <RowStyle BackColor="#EFF3FB" />
                
    <EditRowStyle BackColor="#2461BF" />
                
    <SelectedRowStyle BackColor="#D1DDF1" Font-Bold="True" ForeColor="#333333" />
                
    <PagerStyle BackColor="#2461BF" ForeColor="White" HorizontalAlign="Center" />
                
    <FooterStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
                
    <HeaderStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
                
    <AlternatingRowStyle BackColor="White" />
            
    </asp:GridView>

    aspx.cs文件中啥也不用写

    效果如下: 

     

     不足之处:编辑时只能修改图片链接地址,而无法重新上传图片文件..可以考虑打开新的页面完成操作..不做赘述了就

     

    外加一个参考链接吧:http://hi.baidu.com/yanghuhu/blog/item/22c471ee9b75851afdfa3c1a.html 

  • 相关阅读:
    Valid Palindrome
    Linux经常使用命令(十七)
    JavaSE入门学习8:Java基础语法之方法
    Eclipse导入Maven项目出现错误:Unsupported IClasspathEntry kind=4
    HTTP ERROR 503
    演示账号激活的过程:注冊——&gt;向指定邮箱发送邮件——&gt;用户登录邮箱,激活账号
    Oracle update+with的使用场景
    代理模式(静态代理+动态代理)——JAVA
    BZOJ1611: [Usaco2008 Feb]Meteor Shower流星雨
    BZOJ1724: [Usaco2006 Nov]Fence Repair 切割木板
  • 原文地址:https://www.cnblogs.com/xfiver/p/1730800.html
Copyright © 2011-2022 走看看