setting default value in detailsview template

M

miketayloruk

I'm using a detailsview control that I want to use to insert data to a
table. One of the fields is a date field and I want that to default to
todays date. In classic asp I would do it like this:

<input name="textfield" type="text" value="<%=now()%>" />

How do I do this in ASP.NET, heere is my current code:

<asp:DetailsView ID="DetailsView1" runat="server"
AllowPaging="True" AutoGenerateRows="False" DataKeyNames="data_key"
DataSourceID="SqlDataSource1" Height="50px" Width="125px">
<Fields>
<asp:TemplateField HeaderText="data_key"
InsertVisible="False" SortExpression="data_key">
<InsertItemTemplate>
<asp:TextBox ID="TextBox1" runat="server"
Text='<%# Bind("data_date") %>'></asp:TextBox>
</InsertItemTemplate>
</asp:TemplateField>
<asp:BoundField DataField="data_comment"
HeaderText="data_comment" SortExpression="data_comment" />
<asp:CommandField ShowDeleteButton="True"
ShowEditButton="True" ShowInsertButton="True" />
</Fields>
</asp:DetailsView>

Thanks
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,537
Members
45,022
Latest member
MaybelleMa

Latest Threads

Top