DetailsView Textbox with Bind and Date?

A

AlexUhde

Hello!
I'm relative new to asp.net and I'm trying to figure out how i can
have a "auto fill" date in a textbox from a DetailsView in insertmode.

I know that with <%# Now %> in Text='' I can put the Date in the
TextBox Field.
And I know that i can use <%# Bind="date" %> to bind it to the date
part of the sql query.

But how can I make both with one textbox?
I tried all combinations but i got only errors.

My Code "Part" so far:

<asp:TemplateField HeaderText="Datum" SortExpression="date">
<EditItemTemplate>
<asp:TextBox ID="TextBox5" runat="server"
Text='<%# Bind("date") %>' Width="300px"></asp:TextBox>
<asp:Label ID="Label7" runat="server"
Text="tt.mm.jjjj hh:mm"></asp:Label>
<asp:RequiredFieldValidator
ID="RequiredFieldValidator2" runat="server"
ControlToValidate="TextBox5"
ErrorMessage="Bitte Datum eingeben!"></
asp:RequiredFieldValidator>&nbsp;
</EditItemTemplate>
<InsertItemTemplate>
<asp:TextBox ID="TextBox6" runat="server"
Text='<%# Bind("date") %>'></asp:TextBox>
</InsertItemTemplate>
<ItemTemplate>
<asp:Label ID="Label6" runat="server"
Text='<%# Bind("date") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
 

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,769
Messages
2,569,582
Members
45,069
Latest member
SimplyleanKetoReviews

Latest Threads

Top