|
code
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
OnDayRender won't renderI am stuck with somenthing that I can't get to work. I am trying to color (again) the cell of myCalendar in yellow if those dates match what I ahve in my DB. This is what I have so far: Sub Calendar1_DayRender(sender As Object, e As DayRenderEventArgs) ' Here I define my command Dim strSQL as String = "SELECT dteDataArrivo, dteDataPartenza FROM tblPrenotazioni" ' Creation of DataAdapter passing in the command and the objConnection Dim objDA as New OleDbdataAdapter(strSQL, objConnessione) ' Creating the DS and filling it Dim objDS as New DataSet() objDA.Fill(objDS) ' Now here I try to iterate through all the rows returning dates fields but ....it deosn't work Dim row as DataRow For each row in objDs.Tables(0).Rows If row(0) = e.Day.Date Then e.cell.BackColor = System.Drawing.Color.Yellow End If Next End Sub Thanks for any help you might provide me with...(VB possibly :)) Lorenzo Do you have an OnDayRender attribute within the Calendar element on the ASPX
or an AddHandler statement in your code-behind? Without the event handler, your method won't be called. -- Show quoteHide quoteChristopher A. Reed "The oxen are slow, but the earth is patient." "Lorenzo" <CuTT-!thISoFfonlyLeAveMyNamelorenzoWithNoNuMBErS98776@LeaveMyCountry!!!ITALIANlodging.it.NOSPAM> wrote in message news:unMqFV$$FHA.3372@TK2MSFTNGP12.phx.gbl... > Hello there, > I am stuck with somenthing that I can't get to work. I am trying to color > (again) the cell of myCalendar in yellow if those dates match what I ahve > in my DB. > This is what I have so far: > > Sub Calendar1_DayRender(sender As Object, e As DayRenderEventArgs) > > ' Here I define my command > Dim strSQL as String = "SELECT dteDataArrivo, dteDataPartenza FROM > tblPrenotazioni" > > ' Creation of DataAdapter passing in the command and the objConnection > Dim objDA as New OleDbdataAdapter(strSQL, objConnessione) > > ' Creating the DS and filling it > Dim objDS as New DataSet() > objDA.Fill(objDS) > > > ' Now here I try to iterate through all the rows returning dates fields > but ....it deosn't work > Dim row as DataRow > For each row in objDs.Tables(0).Rows > If row(0) = e.Day.Date Then > e.cell.BackColor = System.Drawing.Color.Yellow > End If > Next > End Sub > > Thanks for any help you might provide me with...(VB possibly :)) > Lorenzo > Hello Chris thanks for your reply. It seems all fine I have the OnDayRender
set on the control in the aspx page. I am doing all this with 'old & cute webMatrix so I don't have codebehind... The error thrown is the following: System.InvalidCastException: Operator is not valid for type 'DBNull' and type 'Date'. It seems that the row(0) I am walking through returns an Integer (even if in this case maybe has found a NULL value) and not a date so then when I compare it to the E.Day.Date throws the error...I tried converting the Integer to a Date but it gets awfully mad at me...:) If the problem is because I have one or more NULL values in my table how do I work around it? Also what If I want to show only the first record retrieved from the DataSet? I mean what if I don't want walking through all the rows but only display the 1st record of a particular column. So far I am successfull counting the rows, finding the columns, but not yet retrieving the first record... Lorenzo Show quoteHide quote "Christopher Reed" <carttu@nospam.nospam> ha scritto nel messaggio news:%23ZV%23Uy$$FHA.2736@TK2MSFTNGP11.phx.gbl... > Do you have an OnDayRender attribute within the Calendar element on the > ASPX or an AddHandler statement in your code-behind? Without the event > handler, your method won't be called. > > -- > Christopher A. Reed > "The oxen are slow, but the earth is patient." > > "Lorenzo" > <CuTT-!thISoFfonlyLeAveMyNamelorenzoWithNoNuMBErS98776@LeaveMyCountry!!!ITALIANlodging.it.NOSPAM> > wrote in message news:unMqFV$$FHA.3372@TK2MSFTNGP12.phx.gbl... >> Hello there, >> I am stuck with somenthing that I can't get to work. I am trying to >> color (again) the cell of myCalendar in yellow if those dates match what >> I ahve in my DB. >> This is what I have so far: >> >> Sub Calendar1_DayRender(sender As Object, e As DayRenderEventArgs) >> >> ' Here I define my command >> Dim strSQL as String = "SELECT dteDataArrivo, dteDataPartenza FROM >> tblPrenotazioni" >> >> ' Creation of DataAdapter passing in the command and the objConnection >> Dim objDA as New OleDbdataAdapter(strSQL, objConnessione) >> >> ' Creating the DS and filling it >> Dim objDS as New DataSet() >> objDA.Fill(objDS) >> >> >> ' Now here I try to iterate through all the rows returning dates >> fields but ....it deosn't work >> Dim row as DataRow >> For each row in objDs.Tables(0).Rows >> If row(0) = e.Day.Date Then >> e.cell.BackColor = System.Drawing.Color.Yellow >> End If >> Next >> End Sub >> >> Thanks for any help you might provide me with...(VB possibly :)) >> Lorenzo >> > > Before your statement [If row(0) = e.Day.Date Then], test it a null value:
If row(0) <> DBNull.Value Then If row(0) = e.Day.Date Then ..... End If End If Hope this helps! -- Show quoteHide quoteChristopher A. Reed "The oxen are slow, but the earth is patient." "Lorenzo" <CuTT-!thISoFfonlyLeAveMyNamelorenzoWithNoNuMBErS98776@LeaveMyCountry!!!ITALIANlodging.it.NOSPAM> wrote in message news:e9rHUAAAGHA.3140@TK2MSFTNGP14.phx.gbl... > Hello Chris thanks for your reply. It seems all fine I have the > OnDayRender set on the control in the aspx page. > I am doing all this with 'old & cute webMatrix so I don't have > codebehind... > > The error thrown is the following: > System.InvalidCastException: Operator is not valid for type 'DBNull' and > type 'Date'. > > It seems that the row(0) I am walking through returns an Integer (even if > in this case maybe has found a NULL value) and not a date so then when I > compare it to the E.Day.Date throws the error...I tried converting the > Integer to a Date but it gets awfully mad at me...:) > If the problem is because I have one or more NULL values in my table how > do I work around it? > > Also what If I want to show only the first record retrieved from the > DataSet? I mean what if I don't want walking through all the rows but only > display the 1st record of a particular column. So far I am successfull > counting the rows, finding the columns, but not yet retrieving the first > record... > > Lorenzo > > > "Christopher Reed" <carttu@nospam.nospam> ha scritto nel messaggio > news:%23ZV%23Uy$$FHA.2736@TK2MSFTNGP11.phx.gbl... >> Do you have an OnDayRender attribute within the Calendar element on the >> ASPX or an AddHandler statement in your code-behind? Without the event >> handler, your method won't be called. >> >> -- >> Christopher A. Reed >> "The oxen are slow, but the earth is patient." >> >> "Lorenzo" >> <CuTT-!thISoFfonlyLeAveMyNamelorenzoWithNoNuMBErS98776@LeaveMyCountry!!!ITALIANlodging.it.NOSPAM> >> wrote in message news:unMqFV$$FHA.3372@TK2MSFTNGP12.phx.gbl... >>> Hello there, >>> I am stuck with somenthing that I can't get to work. I am trying to >>> color (again) the cell of myCalendar in yellow if those dates match what >>> I ahve in my DB. >>> This is what I have so far: >>> >>> Sub Calendar1_DayRender(sender As Object, e As DayRenderEventArgs) >>> >>> ' Here I define my command >>> Dim strSQL as String = "SELECT dteDataArrivo, dteDataPartenza FROM >>> tblPrenotazioni" >>> >>> ' Creation of DataAdapter passing in the command and the objConnection >>> Dim objDA as New OleDbdataAdapter(strSQL, objConnessione) >>> >>> ' Creating the DS and filling it >>> Dim objDS as New DataSet() >>> objDA.Fill(objDS) >>> >>> >>> ' Now here I try to iterate through all the rows returning dates >>> fields but ....it deosn't work >>> Dim row as DataRow >>> For each row in objDs.Tables(0).Rows >>> If row(0) = e.Day.Date Then >>> e.cell.BackColor = System.Drawing.Color.Yellow >>> End If >>> Next >>> End Sub >>> >>> Thanks for any help you might provide me with...(VB possibly :)) >>> Lorenzo >>> >> >> > >
Label Style
Result not expected with user control - any ideas why/ Problem adding attributes to DataListItem.. Role based security Tabbed control for ASP.NET pages Trouble with radio button list in Asp.net 1.1 Templated User Control & intellisense Find the source of an event datagrid value grouping The lowly data field |
|||||||||||||||||||||||