PC Review


Reply
Thread Tools Rate Thread

date problem in datagrid

 
 
harsha reddy
Guest
Posts: n/a
 
      25th Mar 2005


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 MasterDetailReport
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(ByVal year As Integer, ByVal
service As String) As MasterDetailReportCollection
Dim dsData As DataSet =
SqlHelper.ExecuteDataset(ConfigurationSettings.AppSettings(Global.CfgKey
ConnString), "Reports_GetOrderSummary", year, service)
Dim items As New MasterDetailReportCollection

Dim row As DataRow
For Each row In dsData.Tables(0).Rows
Dim item As New MasterDetailReport
item.Month = Convert.ToInt32(row("Month"))
item.TotalSamples = Convert.ToInt32(row("TotalSamples"))
item.Sales = Convert.ToDecimal(row("Sales"))
items.Add(item)
Next row
Return items
End Function 'GetSummary

Public Shared Function GetDetails(ByVal year As Integer, ByVal
month As Integer, ByVal service As String, ByVal study As String) As
MasterDetailReportCollection
Dim dsData As DataSet =
SqlHelper.ExecuteDataset(ConfigurationSettings.AppSettings(Global.CfgKey
ConnString), "Reports_GetOrdersAndDetails", year, month, service, study)
Dim items As New MasterDetailReportCollection

Dim row As DataRow
For Each row In dsData.Tables(0).Rows
Dim item As New MasterDetailReport
item.CellLine = Convert.ToString(row("Cell_Line_Nbr"))
item.Study = Convert.ToString(row("Study"))
item.StudyID = Convert.ToString(row("Study_ID_Nbr"))
item.AltID = Convert.ToString(row("Alternate_ID_Nbr"))
item.DateRec = Convert.ToDateTime(row("Date_Received"))

If service = "Cellline" Then
item.Date1 = Convert.ToDateTime(row("Freeze_1_Date"))
item.Date2 =
Convert.ToDateTime(row("Viability_1_Date"))
ElseIf service = "dnaextraction" Then
item.DNANbr = Convert.ToString(row("DNA_Nbr"))
item.GelDate = Convert.ToDateTime(row("Gel_Date"))



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!
 
Reply With Quote
 
 
 
 
Cor Ligthert
Guest
Posts: n/a
 
      25th Mar 2005
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


 
Reply With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
DataGrid + Access-DB - display date-values grouped by date and time? Olaf Rabbachin Microsoft VB .NET 1 19th May 2005 09:23 AM
problem in nesting datagrid in to a nested datagrid sajvargs Microsoft ASP .NET 0 20th Feb 2005 12:17 AM
Datagrid, empty date: How show nothing for date value - now shows 1/1/0001?? =?Utf-8?B?UmV6YQ==?= Microsoft ASP .NET 1 27th Feb 2004 08:46 PM
asp.net - datagrid and date? Morten Microsoft Dot NET 2 26th Sep 2003 10:48 AM
Date editing problem in datagrid Terry Burns Microsoft ADO .NET 1 12th Aug 2003 04:44 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 01:24 PM.