473,789 Members | 2,893 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

date problem in datagrid



Dear All,
I have a front end form which has a couple of dropdown
menus which select data from the database based on the value selected,
the stored procedure which the program accesses outputs diffrent columns
when different values( currently 2) from the drop down are chosen. I
also have a Datagrid with bound columns which has all the columns that
can be returned, this datagrid has a couple of date columns when i
select one value from the drop down only one of the date columns should
be populated and the other one should give blanks, but the instead of
the blank the valu '1/1/0001' is being populated into the date column,
how can i eliminate this problem.

following is the code for data access layer

Public Class MasterDetailRep ort
Private _cellLine As String
Private _totalSamples As Integer
Private _study As String
Private _studyID As String
Private _altID As String
Private _dateRec As DateTime
Private _date1 As DateTime
Private _date2 As DateTime
Private _month As Integer
Private _sales As Decimal
Private _dnanbr As String
Private _geldate As DateTime


Public Property CellLine() As String
Get
Return _cellLine
End Get
Set(ByVal Value As String)
_cellLine = Value
End Set
End Property

Public Property DNANbr() As String
Get
Return _dnanbr
End Get
Set(ByVal Value As String)
_dnanbr = Value
End Set
End Property

Public Property TotalSamples() As Integer
Get
Return _totalSamples
End Get
Set(ByVal Value As Integer)
_totalSamples = Value
End Set
End Property

Public Property Study() As String
Get
Return _study
End Get
Set(ByVal Value As String)
_study = Value
End Set
End Property

Public Property StudyID() As String
Get
Return _studyID
End Get
Set(ByVal Value As String)
_studyID = Value
End Set
End Property

Public Property AltID() As String
Get
Return _altID
End Get
Set(ByVal Value As String)
_altID = Value
End Set
End Property
Public Property DateRec() As DateTime
Get
Return _dateRec
End Get
Set(ByVal Value As DateTime)
_dateRec = Value
End Set
End Property

Public Property Date1() As DateTime
Get
Return _date1
End Get
Set(ByVal Value As DateTime)
_date1 = Value
End Set
End Property
Public Property GelDate() As DateTime
Get
Return _geldate
End Get
Set(ByVal Value As DateTime)
_geldate = Value
End Set
End Property
Public Property Date2() As DateTime
Get
Return _date2
End Get
Set(ByVal Value As DateTime)
_date2 = Value
End Set
End Property

Public Property Month() As Integer
Get
Return _month
End Get
Set(ByVal Value As Integer)
_month = Value
End Set
End Property

Public Property Sales() As Decimal
Get
Return _sales
End Get
Set(ByVal Value As Decimal)
_sales = Value
End Set
End Property
Public Shared Function GetSummary(ByVa l year As Integer, ByVal
service As String) As MasterDetailRep ortCollection
Dim dsData As DataSet =
SqlHelper.Execu teDataset(Confi gurationSetting s.AppSettings(G lobal.CfgKey
ConnString), "Reports_GetOrd erSummary", year, service)
Dim items As New MasterDetailRep ortCollection

Dim row As DataRow
For Each row In dsData.Tables(0 ).Rows
Dim item As New MasterDetailRep ort
item.Month = Convert.ToInt32 (row("Month"))
item.TotalSampl es = Convert.ToInt32 (row("TotalSamp les"))
item.Sales = Convert.ToDecim al(row("Sales") )
items.Add(item)
Next row
Return items
End Function 'GetSummary

Public Shared Function GetDetails(ByVa l year As Integer, ByVal
month As Integer, ByVal service As String, ByVal study As String) As
MasterDetailRep ortCollection
Dim dsData As DataSet =
SqlHelper.Execu teDataset(Confi gurationSetting s.AppSettings(G lobal.CfgKey
ConnString), "Reports_GetOrd ersAndDetails", year, month, service, study)
Dim items As New MasterDetailRep ortCollection

Dim row As DataRow
For Each row In dsData.Tables(0 ).Rows
Dim item As New MasterDetailRep ort
item.CellLine = Convert.ToStrin g(row("Cell_Lin e_Nbr"))
item.Study = Convert.ToStrin g(row("Study"))
item.StudyID = Convert.ToStrin g(row("Study_ID _Nbr"))
item.AltID = Convert.ToStrin g(row("Alternat e_ID_Nbr"))
item.DateRec = Convert.ToDateT ime(row("Date_R eceived"))

If service = "Cellline" Then
item.Date1 = Convert.ToDateT ime(row("Freeze _1_Date"))
item.Date2 =
Convert.ToDateT ime(row("Viabil ity_1_Date"))
ElseIf service = "dnaextract ion" Then
item.DNANbr = Convert.ToStrin g(row("DNA_Nbr" ))
item.GelDate = Convert.ToDateT ime(row("Gel_Da te"))

End If
items.Add(item)
Next row
Return items
End Function End Class
End Namespace

thank you in advance

harsha

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 21 '05 #1
1 1331
Harsha,

I don't know why you are not using the datetime more standard with its
methods, however, this is in my opinion a class you can have to look too
when I see your problem.

http://msdn.microsoft.com/library/de...classtopic.asp

I hope this helps,

Cor
Nov 21 '05 #2

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

Similar topics

0
990
by: Chumley the Walrus | last post by:
Inside a datagrid that has editcommandcolumns and such, I'm able to format a date variable with DataFormatString ="{0:d}" to display a properly formatted date of 7/14/2004 instead of 7/14/2004 12:00AM. But I have a datagrid that just displays data, and when using : <Columns> <asp:BoundColumn DataField="mydate" HeaderText="My Date" DataFormatString ="{0:d}"
4
2697
by: karunakar | last post by:
Hi All I was poplating Datagrid Datagrid has one of the column showing datetime field format iam showing DATE here not Necessary to populate the Time Frame Even my datebase column also does'nt have any time frame Query is shoing only dates; But ASP.NET dategrid showing Time frame also, How can remove the time frame in datagrid
7
1832
by: Mike L | last post by:
This is for a Win form. SP sends back the PostMark date to my datagrid, shows proper date in datagrid. When user clicks on datagrid, the code sends the current row to text box. The text box shows the date and 12:00:00 AM. How do I get rid of the time? My code below. int rowNum = dgDealerInfo.CurrentCell.RowNumber;
5
724
by: bg | last post by:
Hi! How do I check if "date" exists before using that code? I've built a RSSreader and sometimes there's a date in it and sometimes not. How can I check if it exists to avoid crash (DataBinder.Eval: 'System.Data.DataRowView' does not contain a property with the name date) <asp:DataGrid id="RssNewsGrid"
4
2070
by: Paul | last post by:
Hi, Everything went fine getting a short date format out of SQL into my DataGrid with this: <%# DataBinder.Eval(Container.DataItem, "Created", "{0:d}")%> Then I got too fancy in SQL and started doing a RTRIM(date) when I was retrieving the data. That screwed the pooch big time. Suddenly I lost
5
1310
by: William Gower | last post by:
I have a datagrid that has a column that displays a date. The date is currently being displayed in a long format, I want to format it to display in short format. How do I do that in a datagrid?
4
9636
by: yer darn tootin | last post by:
Does anyone know the sort expression for a column that's data has been returned in the format, eg '07 Jul 05'?? The sort expression {..:"dd mmm yy"} doesn't work ( if the column was returned as '07-Mar-05' the expression {..:dd-MMM-yy} works OK Second question, does anyone know hwo to return a date from SQL server in the format '07-Mar-05', as this would be a workaround. At the moment I'm using CONVERT(varchar(12),columnname,6 ) to...
4
2561
by: steve | last post by:
Hi, First my apologies for double-posting but I am not sure wether this is a VB.Net or TSQL problem. I have the following problem: I generate a T-SQL string in order to fill my Dataset and consecuently a Datagrid. However on the date_time column only the date part is showing : e.g. 2004-08-14
2
5149
by: Derek Vincent | last post by:
What must I do to overcome a problem with my dates becoming formatted as "2/22/2525 12:00:00 AM" in the datagrid? I want to handle all dates as short string of format "2/22/2525." Otherwise when I run the update routine SQL (set start_date = "2/22/2525 12:00:00 AM") does not work while short string (set date = '2/22/2525') does work. See update routine below: Private Sub MarketingDataGrid_UpdateCommand(ByVal source As Object, ByVal e...
1
3087
by: glenn | last post by:
Hi folks, I am using an Access database, VB.NET and ADO.NET working with a DataGrid control. MY datagrid table has both a date_sent and a date_ans field. When I Insert a record in my SQL statement, I insert a date_sent but I need to insert a blank date_ans field. date_sent is the date when a question was sent to a group from a web form and date_ans is the date when a question was answered.
0
9511
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10408
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10199
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10139
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9983
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
5417
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4092
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3697
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2909
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.