zoukankan      html  css  js  c++  java
  • <asp:gridview>使用小结

    1.默认的<asp:CommandField ShowEditButton="true" />灵活性不足,对于需要点击进入详细修改页面时,可以自己改造HyperLinkField实现:

    如下:DataTextFormatString="修改"

     <asp:HyperLinkField DataNavigateUrlFields="NewsID" DataNavigateUrlFormatString="NewsEdit.aspx?NewsID={0}"
                        DataTextField="NewsTitle" HeaderText="编辑" DataTextFormatString ="修改" />

    效果如下:

    编辑

    修改
    修改
    修改

    总而跳转至NewsEdit.aspx?NewsID={0}进行详细修改!

    2.待续~~~

    完成后代码:

    <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ConnectionStrings:ConnectionString%>"
                SelectCommand=" select * from News order by NewsID desc" DeleteCommand="delete from News where NewsID=@NewsID">
            </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="600px" DataKeyNames="NewsID" PageSize="15">
                <Columns>
                    <asp:HyperLinkField DataNavigateUrlFields="NewsID" DataNavigateUrlFormatString="News.aspx?NewsID={0}"
                        DataTextField="NewsTitle" HeaderText="新闻标题" />
                    <asp:BoundField DataField="NewsDate" HeaderText="发布时间" SortExpression="NewsDate" />
                    <asp:BoundField DataField="NewsCategory" HeaderText="新闻种类" SortExpression="NewsCategory" />
                    <asp:HyperLinkField DataNavigateUrlFields="NewsID" DataNavigateUrlFormatString="NewsEdit.aspx?NewsID={0}"
                        DataTextField="NewsTitle" HeaderText="编辑" DataTextFormatString="修改" />
                    <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>

  • 相关阅读:
    gitbook 入门
    mac 手动卸载软件位置
    idea 版本控制忽略文件、文件夹设置
    Mac .DS_Store 隐藏文件和清理.DS_Store的方法
    mac 打开整个系统的隐藏文件
    js拼接字符串,字符串转数组
    新一代 javascript 模板引擎:artTemplate-3.0
    webpack+express多页站点开发
    Vue2学习笔记:组件(Component)
    Vue2学习笔记:过渡效果css
  • 原文地址:https://www.cnblogs.com/xfiver/p/1729818.html
Copyright © 2011-2022 走看看