Home All Groups Group Topic Archive Search About

date problem in datagrid

Author
25 Mar 2005 3:41 PM
harsha reddy
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!

Author
25 Mar 2005 4:14 PM
Cor Ligthert
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/default.asp?url=/library/en-us/cpref/html/frlrfsystemwindowsformsdatagridtextboxcolumnclasstopic.asp

I hope this helps,

Cor