Student
Student

Reputation: 155

Show gregorian calendar as Hijri calendar asp.net web forms

I need to show Hijri Calendar in asp.net webform. for this i am tried to use following code which actually was in VB version http://findanycode.com/54laAAnmwlGw/how-to-display-arabic-dates-in-the-gregorian-calendar.html

I converted this code into C# but it is not compiling

It gives me arror at Foreach loop stated that A query body must end with a select clause

CultureInfo ci = CultureInfo.CreateSpecificCulture("ar-SA");

     Response.Write("<table width=300px>");

foreach (CultureInfo ci in (from c in CultureInfo.GetCultures(CultureTypes.AllCultures) orderby c.Name where c.Name.StartsWith("ar-ae")))
        {
                Thread.CurrentThread.CurrentCulture = CultureInfo.GetCultureInfo(ci.Name);
                Thread.CurrentThread.CurrentUICulture = new CultureInfo(ci.Name);
                Response.Write(string.Format("<tr><td>{0}</td> <td style='direction:rtl;font-size:20px;'>{1:d MMMM yyyy}</td></tr>", ci.Name, Today));

        }

Response.Write("</table>");
Response.End();

Upvotes: 0

Views: 1101

Answers (1)

Dhaval Patel
Dhaval Patel

Reputation: 7601

the error itself told you that you have to select something after filtering the data so your linq query should be

from c in CultureInfo.GetCultures(CultureTypes.AllCultures) orderby c.Name where c.Name.StartsWith("ar-AE") select c;

you can also use below mentioned query

CultureInfo.GetCultures(CultureTypes.AllCultures).Where(p => p.Name.StartsWith("ar-AE")).OrderBy(q => q.Name);

you have used ar-ae it should be ae-AE

Upvotes: 1

Related Questions