Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

VB to C#

Posted on 2006-06-27
6
Medium Priority
?
379 Views
Last Modified: 2008-02-01
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.DayRenderEventArgs) Handles Calendar1.DayRender
       
        Dim datarow1 As DataRow()
        datarow1 = Bookings1.Select( _
        String.Format("Dateto>= #{0}# AND Dateto <#{1}# AND DayDifference = 0", _
         e.Day.Date.ToLongDateString(), e.Day.Date.AddDays(1).ToLongDateString(), e.Day.Date.AddDays(2).ToLongDateString()))

        For Each xlrow As DataRow In datarow1
       ...............................
        Next
End Sub

My C# Attempt:

private void Calendar1_DayRender(object sender, System.Web.UI.WebControls.DayRenderEventArgs e)
            {
                  DataRow[] datarow1;
                  datarow1 = Bookings1.Select(String.Format("Dateto>= #{0}# AND Dateto <#{1}# AND DayDifference = 0",e.Day.Date.ToLongDateString(),                      e.Day.Date.AddDays(1).ToLongDateString()));

                  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
0
Comment
Question by:radhakrishan
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 2
6 Comments
 

Author Comment

by:radhakrishan
ID: 16990999
I guess one more possible error could be that the Day Render function is not called at all in my C# code.
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.
0
 

Author Comment

by:radhakrishan
ID: 16991051
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
0
 
LVL 12

Accepted Solution

by:
Proactivation earned 1200 total points
ID: 16991073
You can use this site to convert your code:

http://www.developerfusion.co.uk/utilities/convertvbtocsharp.aspx
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 

Author Comment

by:radhakrishan
ID: 16991109
Hi Proactivation,

I tried using it but it does not seems to give me the right code for some reason.

0
 
LVL 12

Expert Comment

by:Proactivation
ID: 16991242
What wrong code is it giving you?
0
 

Author Comment

by:radhakrishan
ID: 16991864
Hi,

Thinks its correct peice of code its generating..
cheers
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I recently went through the process of creating a Calendar Control of events with the basis of using a database to keep track of the dates that are selectable, one requirement was to have the selected date pop-up in a simple lightbox.  At first this…
A quick way to get a menu to work on our website, is using the Menu control and assign it to a web.sitemap using SiteMapDataSource. Example of web.sitemap file: (CODE) Sample code to add to the page menu: (CODE) Running the application, we wi…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…
Suggested Courses

688 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question