开发者

Parse asp:boudfield in a gridview

开发者 https://www.devze.com 2023-04-09 08:03 出处:网络
I have the following gridview: I need to parse the first 8 elements of the datetime and view these only in the gridview. How can i do that?

I have the following gridview: I need to parse the first 8 elements of the datetime and view these only in the gridview. How can i do that?

 <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False"  DataKeyNames="ID" BackColor="White"
                    BorderColor="#336666" BorderStyle="Double" BorderWidth="3px"
                    CellPadding="1" DataSourceID="SqlDataSource1"
                    OnRowDataBound="GridView1_RowDataBound" 
                    OnSelectedIndexChanged="GridView1_SelectedIndexChanged" 
                    GridLines="Horizontal" CellSpacing="4" Height="20px" 
                    Width="842px" ShowFooter="True">
                    <FooterStyle BackColor="White" ForeColor="#333333" />
                    <RowStyle ForeColor="#333333" BackColor="White" />
                    <Columns>
                        <asp:ButtonField CommandName="Select" Visible="false" />
                        <asp:BoundField DataField="ID" HeaderText="ID" HeaderStyle-HorizontalAlign="Left" InsertVisible="False" ReadOnly="True" />
                        <asp:BoundField DataField="title" HeaderStyle-HorizontalAlign="Left" HeaderText="Title"/>    
                        <asp:BoundField DataField="location" HeaderStyle-HorizontalAlign="Left" HeaderText="Location"/>
                        <asp:BoundField DataField="datetime" HeaderStyle-HorizontalAlign="Left" HeaderText="Datetime"/>                                               
                    </Columns>
                    <PagerStyle BackColor="#336666" ForeColor="White" HorizontalAlign="Center" />
                    <SelectedRowStyle BackColor="#339966" Font-Bold="True" ForeColor="White" />
                    <HeaderStyle BackColor="#336666" Font-Bold="True" ForeColor="White" />
                </asp:GridView>开发者_开发问答;


Try this:

<asp:BoundField DataFormatString="{0:MM/dd/yy}" DataField="datetime" HeaderStyle-HorizontalAlign="Left" HeaderText="Datetime" />                                               
0

精彩评论

暂无评论...
验证码 换一张
取 消