zoukankan      html  css  js  c++  java
  • GridView中的字符串格式化

     <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" CellPadding="4"
                ForeColor="#333333" GridLines="None" AllowSorting="True" OnRowCancelingEdit="GridView1_RowCancelingEdit"
                OnRowDeleting="GridView1_RowDeleting" OnRowUpdating="GridView1_RowUpdating" PageSize="6"
                OnRowEditing="GridView1_RowEditing" OnRowDataBound="GridView1_RowDataBound1" Height="158px">
                <FooterStyle BackColor="#990000" Font-Bold="True" ForeColor="White" />
                <Columns>
                    <asp:BoundField DataField="UserID" HeaderText="用户ID" ReadOnly="True" />
                    <asp:BoundField DataField="User_Nm" HeaderText="用户姓名" />
                    <asp:BoundField DataField="User_Sex" HeaderText="性别" />
                    <asp:BoundField DataField="User_Address" HeaderText="家庭住址" />
                    <asp:TemplateField HeaderText="出生日期">
                        <EditItemTemplate>
                            <asp:Label ID="Label1" runat="server" Text='<%# Eval("User_Birthday","{0:M-dd-yyyy}") %>'></asp:Label>
                        </EditItemTemplate>
                        <ItemTemplate>
                            <asp:Label ID="Label1" runat="server" Text='<%# Eval("User_Birthday","{0:M-dd-yyyy}") %>'></asp:Label>
                        </ItemTemplate>
                    </asp:TemplateField>
                    <asp:CommandField HeaderText="选择" ShowSelectButton="True" />
                    <asp:CommandField HeaderText="编辑" ShowEditButton="True" />
                    <asp:CommandField HeaderText="删除" ShowDeleteButton="True" />
                </Columns>
                <RowStyle ForeColor="#008066" />
                <SelectedRowStyle BackColor="#669999" Font-Bold="True" ForeColor="White" />
                <PagerStyle BackColor="#006699" Font-Bold="True" ForeColor="White" />
                <HeaderStyle BackColor="#006699" Font-Bold="True" ForeColor="White" />
            </asp:GridView>

    页面后台代码同以前的代码。只是把前台的出生日期作为模板列来操作。

    根据CSDN的清清月儿的写法,还可以<asp:BoundField DataField="User_Birthday" HeaderText ="出生日期" HtmlEncode="false" />

    只需要增加HtmlEncode设置为False。

  • 相关阅读:
    python修改pip源
    python if条件判断dataframe是否为空
    bowtie和bowtie2使用条件区别及用法
    bat批处理for循环嵌套
    常用的数据标准化方法
    python学习——利用循环实现分类散点图绘制
    python学习——通过命令行参数根据fasta文件中染色体id提取染色体序列
    python学习——把读取fasta文件的代码封装成函数
    python学习——把计算GC含量的代码封装成函数
    python学习——使用argparse参数解释器传递命令行参数
  • 原文地址:https://www.cnblogs.com/daiweixm/p/1526187.html
Copyright © 2011-2022 走看看