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 

  • 相关阅读:
    SecureCRT设置
    实战c++中的vector系列--知道emplace_back为何优于push_back吗?
    Dalvikvm工具
    智能高速充电
    HTML5标准最终来了,看什么书学习最好??????
    Android平台调用Web Service:线程返回值
    C 多级指针
    C 指向指针的指针
    C 字符串
    C while循环的自增和自减
  • 原文地址:https://www.cnblogs.com/xfiver/p/1730800.html
Copyright © 2011-2022 走看看