Search code examples
c#sql-serverwinformsentity-frameworkrdlc

How to display Hindi Characters in rdlc report viewer in winform c#


Please provide me the solution for this issue.

I have saved record in sql with hindi language, but when i display in rdlc report viewer it shows as a boxes.

  1. SQL Database - I have saved record in hindi.

enter image description here

  1. Service Code

     public class PaperRptModel
     {
         public string Subject { get; set; }
         public string Course { get; set; }
         public string Time { get; set; }
         public int MaxMarks { get; set; }
         public int PassMarks { get; set; }
    
         readonly PaperGenEntities paperGenEntities = new PaperGenEntities();
    
         public IList GetSingle(int Id)
         {
             List<PaperRptModel> paperRpts = new List<PaperRptModel>();
             PaperRptModel model = new PaperRptModel();
             var paper = paperGenEntities.Papers.FirstOrDefault(o => o.Id == Id);
             var subject = paperGenEntities.Subjects.FirstOrDefault(o => o.Id == paper.Subject);
             model.Course = $"{subject.EnglishCourse} ({subject.HindiCourse})";
             model.Subject = $"{subject.EnglishName} ({subject.HindiName})"; ;
             model.Time = paper.MaxTime;
             model.MaxMarks = paper.TotalMarks ?? 0;
             model.PassMarks = paper.PassMarks ?? 0;
             paperRpts.Add(model);
             return paperRpts;
         }
    
         public IList GetQuestions(int Id)
         {
             List<Question> questions = new List<Question>();
             Question model = new Question();
             var question = paperGenEntities.Questions.FirstOrDefault(o => o.Subject == Id);
             model.EnglishName = question.EnglishName;
             model.HindiName = question.HindiName;
             model.DisplayMarks = question.DisplayMarks;
             questions.Add(model);
             return questions;
         }
    
  2. Window Form Code

     public partial class Form2 : Form
     {
         public Form2()
         {
             InitializeComponent();
         }
    
         private void Form2_Load(object sender, EventArgs e)
         {
             this.reportViewer1.LocalReport.DataSources.Clear();
             var rptModel = new PaperRptModel();
             var Model = rptModel.GetSingle(1);
             var rds1 = new ReportDataSource("DataSet1", Model);
             this.reportViewer1.LocalReport.DataSources.Add(rds1);
    
             var question = new Question();
             var questions = rptModel.GetQuestions(1);
             var rds2 = new ReportDataSource("DataSet2", questions);
             this.reportViewer1.LocalReport.DataSources.Add(rds2);
             this.reportViewer1.RefreshReport();
         }
     }
    
  3. Result as boxes enter image description here


Solution

  • If you running this in a windows client

    check whether you have installed the Hindi language

    enter image description here (windows 10)