radhakrishan
asked on
VB to C#
Hello Experts,
I am trying to convert code from Vb to C#, and the code seems to work in VB but nothing happens in C#.
Any help would be really appreciated.
--Code
VB:
Private Sub Calendar1_DayRender(ByVal sender As Object, ByVal e As System.Web.UI.WebControls. DayRenderE ventArgs) Handles Calendar1.DayRender
Dim datarow1 As DataRow()
datarow1 = Bookings1.Select( _
String.Format("Dateto>= #{0}# AND Dateto <#{1}# AND DayDifference = 0", _
e.Day.Date.ToLongDateStrin g(), e.Day.Date.AddDays(1).ToLo ngDateStri ng(), e.Day.Date.AddDays(2).ToLo ngDateStri ng()))
For Each xlrow As DataRow In datarow1
.......................... .....
Next
End Sub
My C# Attempt:
private void Calendar1_DayRender(object sender, System.Web.UI.WebControls. DayRenderE ventArgs e)
{
DataRow[] datarow1;
datarow1 = Bookings1.Select(String.Fo rmat("Date to>= #{0}# AND Dateto <#{1}# AND DayDifference = 0",e.Day.Date.ToLongDateSt ring(), e.Day.Date.AddDays(1).ToLo ngDateStri ng()));
foreach(DataRow xlrow in datarow1)
{
.......................... .......... .......... ..
}
I guess the trouble is with how the datarow is being defined and implemented in C#, probably its not right.
Cheers
I am trying to convert code from Vb to C#, and the code seems to work in VB but nothing happens in C#.
Any help would be really appreciated.
--Code
VB:
Private Sub Calendar1_DayRender(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.
Dim datarow1 As DataRow()
datarow1 = Bookings1.Select( _
String.Format("Dateto>= #{0}# AND Dateto <#{1}# AND DayDifference = 0", _
e.Day.Date.ToLongDateStrin
For Each xlrow As DataRow In datarow1
..........................
Next
End Sub
My C# Attempt:
private void Calendar1_DayRender(object
{
DataRow[] datarow1;
datarow1 = Bookings1.Select(String.Fo
foreach(DataRow xlrow in datarow1)
{
..........................
}
I guess the trouble is with how the datarow is being defined and implemented in C#, probably its not right.
Cheers
ASKER
Hi Guys,
I changed the name of the function to DayRender and added the line to the Page Load Event:
Calendar1.DayRender += new DayRenderEventHandler(this .DayRender );
But doing this the code runs, but it does not take the default settings of the Calendar such as backcolors and stuff...
And to change the color of the cell in C#
is the following code not correct:
e.Cell.BackColor = Color.Aqua;
or
e.Cell.BackColor = System.Drawing.Color.Aqua;
Cheers
I changed the name of the function to DayRender and added the line to the Page Load Event:
Calendar1.DayRender += new DayRenderEventHandler(this
But doing this the code runs, but it does not take the default settings of the Calendar such as backcolors and stuff...
And to change the color of the cell in C#
is the following code not correct:
e.Cell.BackColor = Color.Aqua;
or
e.Cell.BackColor = System.Drawing.Color.Aqua;
Cheers
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Hi Proactivation,
I tried using it but it does not seems to give me the right code for some reason.
I tried using it but it does not seems to give me the right code for some reason.
What wrong code is it giving you?
ASKER
Hi,
Thinks its correct peice of code its generating..
cheers
Thinks its correct peice of code its generating..
cheers
ASKER
I wrote Response.Write statement in it and it was'nt printed out...
So it might not be going in that function at all.
Sorry Guys, I am very new to C# stuff.