<asp:GridView ID="GridView2" runat="server" AllowSorting="True"
        AutoGenerateColumns="False" BorderColor="Maroon" BorderStyle="Outset" BorderWidth="2px"
        CellPadding="4" DataKeyNames="TJID" ForeColor="Maroon"
        GridLines="None" Width="100%" DataSourceID="CXSqlDataSource" ShowHeader="False" PageSize="5">
        <FooterStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
        <Columns>
            <asp:CommandField ShowDeleteButton="True" ShowEditButton="True" ShowSelectButton="True" />
            <asp:BoundField DataField="TJID" HeaderText="序号" InsertVisible="False" ReadOnly="True"
                SortExpression="TJID" />
            <asp:BoundField DataField="TJModel" HeaderText="型号" SortExpression="TJModel" />
            <asp:BoundField DataField="TJSize" HeaderText="体积" SortExpression="TJSize" />
            <asp:BoundField DataField="TJSizeSum" HeaderText="单个体积" SortExpression="TJSizeSum" />
            <asp:TemplateField HeaderText="更新时间" SortExpression="TJUpdateTime">
                <EditItemTemplate>
                    <asp:TextBox ID="TextBox1" runat="server" Text='<%# now() %> '></asp:TextBox>
                </EditItemTemplate>
                <ItemTemplate>
                    <asp:Label ID="Label1" runat="server" Text='<%# Bind("TJUpdateTime") %>'></asp:Label>
                </ItemTemplate>
            </asp:TemplateField>
            <asp:BoundField DataField="TJRe" HeaderText="备注" SortExpression="TJRe" />
        </Columns>
        <RowStyle BackColor="#EFF3FB" />
        <EditRowStyle BackColor="#2461BF" />
        <SelectedRowStyle BackColor="#D1DDF1" Font-Bold="True" ForeColor="#333333" />
        <PagerStyle BackColor="#2461BF" ForeColor="White" HorizontalAlign="Center" />
        <HeaderStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
        <AlternatingRowStyle BackColor="White" />
    </asp:GridView>如下面红色的部份。
在编辑模式下能显示为当前时间,但点确认更新已后写入数据库的值为空,不知怎么处理.

解决方案 »

  1.   

    <asp:TextBox ID="TextBox1" runat="server" Text=' <%= now() %> '> </asp:TextBox>

    <asp:TextBox ID="TextBox1" runat="server" Text=' <%=DateTime.Now %> '> </asp:TextBox>
    试试
      

  2.   

    没有必要搞这么复杂吧,直接在后台获取时间,然后在SQL中增加一个更新项,不就可以了吗在快的话,写一个触发器
      

  3.   

    写一个更新的存储过程,然后传参数时更新参数不要传,在存储过程里用getdate()进行获取时间保存
      

  4.   

     <asp:TextBox ID="TextBox1" runat="server" Text=' <%# System.DateTime.Now %> '> </asp:TextBox>
     <asp:TextBox ID="TextBox1" runat="server" Text=' <%# System.DateTime.Today %> '> </asp:TextBox> 
      

  5.   

    普通的双向绑定要使用 Bind 在绑定表达式中。如果是单向的,那么你是如何更新到数据库的呢?因为看不到你的更新方法的代码,我只能举一种比较正规的,当你使用某种DataSource控件时(不论哪一种),那么只要在 RowUpdating 事件处理中写一行代码:e.NewValues["在BLL方法中定义的时间参数名称"]=((TextBox)GridView2.Rows[e.RowIndex].FindControl("TextBox1")).Text;你没有写明你是如何更新数据库的。如果写了一大堆手写代码,那么提交更新数据时也就可能不能这样用一行代码来写,很可能还要多写很多行。从你的html代码的声明来看,没有利用到现成的数据源控件,那么很可能是这种写一大堆手写代码的写法。