databinding for datetime datatype

G

Guest

How to define databinding for 'datetime' data type ?

( Xxx = '<%# Bind("Datetime") %>' )

Thank you.

Pen
 
G

Guest

I am trying to use either 'Bind' or 'Eval' to store (insert a record) the
DateTime.now() info to SQL 2005 database table through the FormView.

Thank you.
 
G

Guest

I am trying to use either 'Bind' or 'Eval' to store (insert a record) the
DateTime.now() info to SQL 2005 database table through the FormView.

I think you have to specify the type of your variable

<UpdateParameters>
<asp:parameter Name="Datetime" Type="DateTime" />

.....

( Xxx = '<%# Bind("Datetime") %>' )
 
G

Guest

I think it is:
<InsertParameters>
<asp:parameter Name="Datetime" Type="DateTime" />
</InsertParameters>


But, how to define the two-way binding in FormView and code-behind (onClick)
for the 'xxx', 'yyy', 'Zzz' and 'aaa' shown below:

<asp:xxx ID="Datetime1" runat="server"
yyy='<%# Bind("Datetime") %>'
Visible="False">
</asp:xxx>


The code behind is something like:
Zzz var = (Zzz) FormView1.Row.FindControl("Datetime1");
var.aaa= System.DateTime.Now();

Thank you
 
G

Guest

I think it is:
<InsertParameters>
<asp:parameter Name="Datetime" Type="DateTime" />
</InsertParameters>

But, how to define the two-way binding in FormView and code-behind (onClick)
for the 'xxx', 'yyy', 'Zzz' and 'aaa' shown below:

<asp:xxx ID="Datetime1" runat="server"
yyy='<%# Bind("Datetime") %>'
Visible="False">
</asp:xxx>

The code behind is something like:
Zzz var = (Zzz) FormView1.Row.FindControl("Datetime1");
var.aaa= System.DateTime.Now();

Thank you

--
Pen







- Show quoted text -


I think you should get the date from the data source. SQL Server has
the GetDate() function to get the date and time of the DB-server. You
can use that function in your SqlDataSource, for example "SELECT ....,
getdate() as Datetime FROM....

After that, I think, you will be able to bind that field in the
FormView.

I'm not sure if it's working, please test.

If it is working, I must say, it makes no sense. You can always use an
INSERT query with the getdate() function without binding a FormView to
any date control...
 

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

Forum statistics

Threads
473,816
Messages
2,569,710
Members
45,497
Latest member
GregoryCur

Latest Threads

Top