0

再次,新问题。请参考下图。

在此处输入图像描述

这是输出(见下图): 在此处输入图像描述

这是我在 results.aspx 中的 Gridview 的代码

<asp:GridView runat="server" id="GridView1" AutoGenerateColumns="False" DataSourceID="AccessDataSource1" DataKeyNames="ID" BorderStyle="Ridge" BackColor="White" BorderColor="Black" BorderWidth="3px" CellPadding="3" Width="1000px" AllowPaging="True" PageSize="2">
            <RowStyle BackColor="White" ForeColor="#003399" HorizontalAlign="Center" VerticalAlign="Middle" />
            <Columns>
                <asp:boundfield DataField="Time In" HeaderText="Time In" SortExpression="Time In">
                    <ItemStyle Width="100px" />
                </asp:boundfield>
                <asp:boundfield DataField="Username" HeaderText="Bar Code No." SortExpression="Username">
                </asp:boundfield>
                <asp:boundfield DataField="FirstName" HeaderText="First Name" SortExpression="FirstName">
                </asp:boundfield>
                <asp:boundfield DataField="LastName" HeaderText="Last Name" SortExpression="LastName">
                </asp:boundfield>
                <asp:boundfield DataField="MiddleName" HeaderText="Middle Name" SortExpression="MiddleName">
                </asp:boundfield>
                <asp:boundfield DataField="ContactNumber" HeaderText="Contact No." SortExpression="ContactNumber">
                </asp:boundfield>
                <asp:boundfield DataField="PlateNumber" HeaderText="Plate No." SortExpression="PlateNumber">
                </asp:boundfield>
                <asp:boundfield DataField="Color" HeaderText="Color" SortExpression="Color">
                </asp:boundfield>
                <asp:boundfield DataField="Brand" HeaderText="Brand" SortExpression="Brand">
                </asp:boundfield>
                <asp:boundfield DataField="LiscensedNumber" HeaderText="Liscensed No." SortExpression="LiscensedNumber">
                </asp:boundfield>
                <asp:templatefield>
                    <HeaderTemplate>
                        Image
                    </HeaderTemplate>
                    <ItemTemplate>
                        <img src="data:image/jpg;base64,<%# Eval("Image") != System.DBNull.Value ? Convert.ToBase64String((byte[])Eval("Image")) : string.Empty %>" alt="image" height="85" width="85" />
                    </ItemTemplate>
                </asp:templatefield>
            </Columns>
            <FooterStyle BackColor="#CCCCCC" ForeColor="Black" />
            <PagerStyle HorizontalAlign="Center" BackColor="#999999" ForeColor="#003399" />
            <EmptyDataTemplate>
                No data found!
            </EmptyDataTemplate>
            <SelectedRowStyle BackColor="#008A8C" Font-Bold="True" ForeColor="White" />
            <HeaderStyle BackColor="#A0A0A0" Font-Bold="True" ForeColor="#003399" HorizontalAlign="Center" />
            <AlternatingRowStyle BackColor="#DCDCDC" />
        </asp:GridView>

请帮忙。我不知道有关“日期和时间”的代码。

4

3 回答 3

1
<asp:boundfield datafield="Your_Date_Column" dataformatstring="{0:MMMM d, yyyy}" htmlencode="false" />

还要确保数据字段名称中没有空格

于 2013-01-30T11:58:49.080 回答
1

尝试删除数据字段中的空格,如 Rahul R 所言。在标题文本中无关紧要,但在数据字段中却可以。

于 2013-01-30T11:57:02.683 回答
0

抱歉在这里问,我解决了。

我转换了模板字段中的列,然后添加了这段代码

Text='<%# DateTime.Now.ToString("dddd<br /> MMMM dd,  yyyy<br /> hh:mm tt") %> 

:) 感谢大家。

于 2013-01-30T14:13:12.700 回答