正在尝试绑定DateTime.现在在gridview中



我正在使用Visual Web Developer Express 2013,并创建了一个网格视图。当我更新网格中的其他值时,我希望txtDate显示更新值的时间。我将其设置为项目模板。

<asp:TemplateField HeaderText="txtDate" SortExpression="txtDate">
<itemtemplate><asp:label id="txtDate" runat="server" 
 text="<%# Bind DateTime.Now.ToString()%>"></asp:label>    
</itemtemplate>
</asp:TemplateField>

当我在没有绑定的情况下使用上述代码时,我会显示当前时间。我添加了Bind,以便将当前日期插入数据库,我得到了以下错误;编译器错误消息:CS1026:)应为

我正试图找出在更新值时插入日期的最佳方式。我还尝试将txtDate添加为隐藏字段,但也不起作用。

在插入查询中直接使用GetDate()函数,您不需要向用户显示此函数,因为据我所知,它只是用于日志记录。

最新更新