hi
I have label in grid view that will bind Date from database according below code it will change date to persian date:
<asp:TemplateField ItemStyle-Width="100px" ItemStyle-HorizontalAlign="Center" ItemStyle-VerticalAlign="Middle">
<ItemTemplate>
<asp:Label ID="Label11" runat="server" CssClass="lbldateS"><%# miladitoshamsi(Eval("Date"))%></asp:Label>
</ItemTemplate>
</asp:TemplateField>
public string miladitoshamsi(object miladi1)
{
DateTime miladi = Convert.ToDateTime(miladi1);
System.Globalization.PersianCalendar shamsi = new System.Globalization.PersianCalendar();
return string.Format("{0}/{1}/{2} {3}:{4}:{5}", shamsi.GetYear(miladi), shamsi.GetMonth(miladi), shamsi.GetDayOfMonth(miladi), shamsi.GetHour(miladi), shamsi.GetMinute(miladi), shamsi.GetSecond(miladi));
}
now refer below thread:
http://www.aspforums.net/Threads/837427/Conver-numeric-digit-to-persian-arabic-in-GridView-using-C-in-ASPNet/
I want use above code for this label that show date in persian font but I don't know how I can merg two metod:
public string miladitoshamsi(object miladi1)
{
DateTime miladi = Convert.ToDateTime(miladi1);
System.Globalization.PersianCalendar shamsi = new System.Globalization.PersianCalendar();
return string.Format("{0}/{1}/{2} {3}:{4}:{5}", shamsi.GetYear(miladi), shamsi.GetMonth(miladi), shamsi.GetDayOfMonth(miladi), shamsi.GetHour(miladi), shamsi.GetMinute(miladi), shamsi.GetSecond(miladi));
}
public string toPersianNumber(string input)
{
string[] persian = new string[10] { "۰", "۱", "۲", "۳", "۴", "۵", "۶", "۷", "۸", "۹" };
for (int j = 0; j < persian.Length; j++)
{
input = input.Replace(j.ToString(), persian[j]);
}
return input;
}
Best Regards
Neda