Click here to Skip to main content
15,888,521 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello Sir,
Sir i have made a calenar control by own and now i want to convert that calendar in hindi but as i use the culture for this work it gives error ie; "Conversion from string "06-29-2011" to type 'Date' is not valid".
Now i am unable to understand that how to convert the date into the specific culture ie; hindi?
Sir i wanna share some code

VB
Protected Sub MonthPage_ImageButton1_Click(ByVal sender As Object, ByVal e As System.Web.UI.ImageClickEventArgs) Handles MonthPage_ImageButton1.Click
        Dim cultureInfo As New CultureInfo("hi-IN")
        Thread.CurrentThread.CurrentCulture = cultureInfo
        cultureInfo.DateTimeFormat.Calendar = New GregorianCalendar
        Dim dnow As DateTime = Now()  'take a dnow variable as a datetime.
   Error is coming here:     ReloadCal(dnow.ToString("MM/dd/yyyy")) ''Call the function Reloadcal to dispaly the dates of Month and creating a calendar.
        Month_PlaceHolder1.Visible = True 'show the Calendar control.
        showMonth() 'call a function show month which display Current onth at calendar.
        GetMonthName() 'call a function getmonthname which  display numeric value of month.
        Monthpage_TextBox1.Text = "" 'take a textbox and empty it.


    End Sub


VB
Public Sub ReloadCal(ByVal ldate As Date) 'creating a function  to create calendar and display dates on it.
        On Error Resume Next 'Proceed the next line after comming the error .
        Me.Refresh() 'Call Refresh function to refresh the backgroung image for date in calendar.
        Me.ClearAll() 'clear all the text of linkbuttons for date.


        Dim fdate As DayOfWeek = GetFirstOfMonthDay(ldate) 'take a fdate variable as dayofweek. and assign the result ehich is getting form the function  GetFirstOfMonthDay().
        Dim idate As Integer = 1 'take a variable idate as integer and assign it to 1.
        Dim row As Integer = 1 'take a variable row  as integer and assign it to 1.
        Do
            getlinkbutton(fdate, row).Text = idate 'call a function getlinkbutton which didsplay all the dates at calendar.


            If fdate = DayOfWeek.Saturday Then  'here check the end of the week is saturday or not.
                row += 1 'increment the row of table .
            End If
            fdate = tdate(fdate) 'assign the result of function tdate in fdate variable.
            idate += 1  'increment the idate .
            If idate = Date.DaysInMonth(ldate.Year, ldate.Month) + 1 Then 'check here is the date is the last date of the month taht it is 31 or 30 according  to system date .
                Exit Do 'if it is the last date of month then exit from do while loop.
            End If
        Loop ' end of the do while loop.

    End Sub

please give any possible solution.

Thank You


[edit]"Ignore HTML..." option disabled - OriginalGriff[/edit]
Posted
Updated 28-Jun-11 21:12pm
v2

1 solution

Spot the deliberate mistake:
ReloadCal(dnow.ToString("MM/dd/yyyy")) ''Call the function Reloadcal to dispaly the dates of Month and creating a calendar.

Public Sub ReloadCal(ByVal ldate As Date) 'creating a function  to create calendar and display dates on it.

If you have the date as a DateTime, why convert it to a string, to then try to hand it to a function taking a DateTime, which will just try to convert it back to a DateTime using the default culture? Why not just hand over the fully fledged and working DateTime you started with?
 
Share this answer
 
Comments
SURBHI TYAGI 29-Jun-11 3:21am    
Sorry,I did not get you sir.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900