Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Windows Forms / WinForm General / December 2004

Tip: Looking for answers? Try searching our database.

DateTime Bound to  TextBox

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
mark - 30 Nov 2004 13:57 GMT
Hi,

I have bound a DateTime field in a DataTable to a TextBox field.  Other
String and Numeric fields are also bound to separate TextBoxes.  If a new
DataRow is created and a DateTime value is entered no problem.  However,
after the row is saved, I am unable to clear the date from the textbox.

I do not have this problem when binding to a DataGrid.  But a DataGrid is
far from user friendly and just plain impractical in many situations.  

In its place I am loading the DataRow into a class and using unbound fields
on the form.   Bound controls seem great for strings.  But thats about it.  
Does anyone have a better solution?

Thanks
Sijin Joseph - 01 Dec 2004 08:59 GMT
Try writing Format and Parse event handlers for the binding to convert
empty string to empty datetime

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlr
fSystemWindowsFormsBindingClassFormatTopic.asp


http://www.akadia.com/services/dotnet_databinding.html#Format%20and%20Parse%20Ev
ents%20of%20the%20Binding%20Class

http://www.eggheadcafe.com/ng/microsoft.public.dotnet.framework.windowsforms.dat
abinding/post109933.asp


Sijin Joseph
http://www.indiangeek.net
http://weblogs.asp.net/sjoseph

> Hi,
>
[quoted text clipped - 11 lines]
>
> Thanks
mark - 02 Dec 2004 18:25 GMT
Sijin,
I'm a bit confused about the meaning of an empty DateTime.  
Are you saying set this field to DBNull in the Parse event? Because
a DateTime cannot be set to null. The runtime throws an error.
Thanks

> Try writing Format and Parse event handlers for the binding to convert
> empty string to empty datetime
[quoted text clipped - 23 lines]
> >
> > Thanks

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.