我正在尝试在我的网格视图的edititemtemplate中有一个标签,当用户点击编辑链接按钮时显示当前的日期和时间。当我将date.now放到数据绑定框中时,我可以看到我想要的结果,但是当我单击update时,我得到一个错误,字段不能为空。当我在脚注行上尝试它时,它工作得很好,但在编辑行上却不行。下面是有效的脚注行代码:
'Get Time Recorded
Dim lblFtrTimeRecorded As Label = GridView1.FooterRow.FindControl("lblFtrTimeRecorded")
lblFtrTimeRecorded.Text = Date.Now以下是模板字段.aspx代码:
<asp:TemplateField HeaderText="TimeRecorded" SortExpression="TimeRecorded">
<EditItemTemplate>
<asp:Label ID="lblEditTimeRecorded" runat="server"
Text='<%# Bind("TimeRecorded") %>'></asp:Label>
</EditItemTemplate>
<FooterTemplate>
<asp:Label ID="lblFtrTimeRecorded" runat="server"></asp:Label>
</FooterTemplate>
<ItemTemplate>
<asp:Label ID="lblTimeRecorded" runat="server"
Text='<%# Bind("TimeRecorded") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>任何帮助都是非常感谢的!
发布于 2014-01-31 21:06:51
编写以下代码:
Dim lblFtrTimeRecorded As Label = GridView1.Rows[GridView1.EditIndex].FindControl("lblFtrTimeRecorded")
lblFtrTimeRecorded.Text = Date.Nowhttps://stackoverflow.com/questions/21480646
复制相似问题