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>

  • 相关阅读:
    [Istio]流量管理API v1alpha3路由规则
    [Istioc]Istio部署sock-shop时rabbitmq出现CrashLoopBackOff
    [Go]指针操作
    [Go]接口的运用
    [Go]结构体及其方法
    [Kubernetes]Volume
    [Kubernetes]kubectl命令补全出错
    [Docker]容器镜像
    [Docker]容器的隔离与限制
    [Go]通道(channel)的基本操作
  • 原文地址:https://www.cnblogs.com/xfiver/p/1729818.html
Copyright © 2011-2022 走看看