473,387 Members | 1,464 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Binding a textbox to current date

Hi

How can I bind a textbox to current date in asp.net 2.0.

I want to achieve the same result that I will get when i am using
TextBox1.Text = System.DateTime.Now.ToString();
by binding in the aspx file(in the mark up for text box)

Jan 2 '07 #1
5 21839
"ar**@greettech.com" <ar**@visrez.comwrote in message
news:11*********************@48g2000cwx.googlegrou ps.com...
How can I bind a textbox to current date in asp.net 2.0.

I want to achieve the same result that I will get when i am using
TextBox1.Text = System.DateTime.Now.ToString();
by binding in the aspx file(in the mark up for text box)
Works for me - what error(s) are you getting...?
Jan 2 '07 #2
Thanks for replying.

I want to achieve the result by modifying the mark up like
<asp:TextBox ID="BookingDate" runat="server" Text='<% # Binding
Expression %>'></asp:TextBox>

I dont know how to achieve this and what should be the " Binding
Expression"

Jan 2 '07 #3
<asp:TextBox runat="server" Text="<%# System.DateTime.Now.ToString() %>" />

Don't forget to call DataBind method for either the page or the textbox.

--
Eliyahu Goldin,
Software Developer & Consultant
Microsoft MVP [ASP.NET]
http://msmvps.com/blogs/egoldin
http://usableasp.net
"ar**@greettech.com" <ar**@visrez.comwrote in message
news:11**********************@48g2000cwx.googlegro ups.com...
Thanks for replying.

I want to achieve the result by modifying the mark up like
<asp:TextBox ID="BookingDate" runat="server" Text='<% # Binding
Expression %>'></asp:TextBox>

I dont know how to achieve this and what should be the " Binding
Expression"

Jan 2 '07 #4
"ar**@greettech.com" <ar**@visrez.comwrote in message
news:11**********************@48g2000cwx.googlegro ups.com...
I want to achieve the result by modifying the mark up like
<asp:TextBox ID="BookingDate" runat="server" Text='<% # Binding
Expression %>'></asp:TextBox>
Is there any particular reason you want to do it this way...? Seems like
you're just making work for yourself...
Jan 2 '07 #5
On 2 Jan 2007 04:29:08 -0800, ar**@greettech.com wrote:
Thanks for replying.

I want to achieve the result by modifying the mark up like
<asp:TextBox ID="BookingDate" runat="server" Text='<% # Binding
Expression %>'></asp:TextBox>

I dont know how to achieve this and what should be the " Binding
Expression"
Hey Arun,

Try DateTime.Now. It is a valid binding expression
--
Bits.Bytes
http://bytes.thinkersroom.com
Jan 2 '07 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: PawelR | last post by:
Hello group I have problem with binding data to textBox. If in dataBease - dataSet I'va varchar or char I use: textBox1.DataBindings.Add(new Binding("Text",myDS ,"MyTable.MyColumn")); If I want...
1
by: TN Bella | last post by:
Hello, I was looking through the older posts for a solution to this problem, but I am still confused on how to fix my problem. There are two dates on my form, one (txtInvDate) is entered by the...
6
by: shariffshiraz | last post by:
I am using a FormView, Insert Template. I have 3 textboxes which are bound. I would like to use a default (static) value in one of the textboxes. Here's the (relevant) sample code: ...
3
by: Slonocode | last post by:
I have some textboxes bound to an access db. I wanted to format the textboxes that displayed currency and date info so I did the following: Dim WithEvents oBidAmt As Binding oBidAmt = New...
5
by: Brad Shook | last post by:
I am trying to bind one column of a datagrid to a seperate textbox and the rest of the fields to a datagrid. the comments are too large to fit in a datagrid so I created a textbox below the...
1
by: Bruce | last post by:
Hi, there, I meet a problem about comboBox binding. -------------------- Database: Northwind Tables: 1) Products 2) Categories I create a form (named "form1") to edit the record from...
2
by: Matthias | last post by:
Hi Team this may be a newbie question. I have searched the discussions before posting: I'd like to re-use a form instance to edit record details. My data binding (a DataTable bound to...
1
by: Smash | last post by:
I have problem binding gridview.... At first i didn't want to bind gridview at first page load...so in my objectdatasource_selecting event i wrote this: If Not Page.IsPostBack Then e.Cancel =...
6
by: Dmitry Duginov | last post by:
Hi, I have the following label markup (label is inside FormView): <asp:Label ID="lblIndicatorReady" runat="server" Text="RE" ToolTip="Ready" BackColor='<%#...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.