2012-04-19 18 views

cevap

8
+0

Teşekkürler Pranay ... Bu temel dersler bana yardımcı olur ... –

+1

@SonamMohite - buyurun .. Cevap vermemek için bekliyorum .. –

+0

Hey Pranay .... İlk yardım için teşekkürler . Sadece Veri Tabanı ile Tablo ile iyi çalıştım, şimdi bu bir denemek isteyebilirsiniz.Sadece sizin için kod yazabilirsiniz.Yanıtlanmış Procedures ile Veri Kümesi oluşturma konusunda küçük bir karışıklık var. –

1

Kodum (ASP.NET/ C#) 1.Create Öğrenci Sınıfı İş Class kullanarak Raporu Oluşturma

& ReportViewer Nesneleri ... business class nesneler için Rapor oluşturmak

public class StudentClass 
    { 
     public int No { get; set; } 
     public string Name { get; set; } 
     public string Degree { get; set; } 
    } 

2.Create Öğrenci işleri GetStudents ile Deposu() fonksiyonu

public class StudentRepository : StudentClass 
    { 
     public List<StudentClass> studentList = new List<StudentClass>(); 

     public List<StudentClass> GetStudents() 
     {    
      StudentClass student1 = new StudentClass(); 
      student1.No = 1; 
      student1.Name = "Bhuvana"; 
      student1.Degree = "M.Tech"; 
      studentList.Add(student1); 
      StudentClass student2 = new StudentClass(); 
      student2.No = 2; 
      student2.Name = "Annie"; 
      student2.Degree = "B.Tech"; 
      studentList.Add(student2); 
      StudentClass student3 = new StudentClass(); 
      student3.No = 3; 
      student3.Name = "Muthu Abi"; 
      student3.Degree = "B.Tech"; 
      studentList.Add(student3); 
      return studentList; 
     } 
    } 

3.Ünitenin Rapor Sihirbazı “StudentReport.rdlc” oluşturmak ve seçmek DataSource

4.In index.aspx dosyasında kodda ToolBox'den (Sürükle ve Bırak)

<div> 
    <asp:ScriptManager ID="ScriptManager1" runat="server"> 
    </asp:ScriptManager> 
    <rsweb:ReportViewer ID="ReportViewer1" runat="server"> 
    </rsweb:ReportViewer>  
</div> 

5.Modify Page_Load() yöntemini Senaryo Yöneticisi ve Rapor Görüntüleyici eklemek

public partial class Index : System.Web.UI.Page 
{ 
    StudentRepository sr = new StudentRepository(); 
    List<StudentClass> sc = new List<StudentClass>(); 
    protected void Page_Load(object sender, EventArgs e) 
    { 
     if (!IsPostBack) 
     { 
      ReportViewer1.ProcessingMode = ProcessingMode.Local; 
      ReportViewer1.LocalReport.ReportPath = Server.MapPath("~/Report/Student.rdlc"); 
      sc = sr.GetStudents(); 
      IEnumerable<StudentClass> ie; 
      ie = sc.AsQueryable(); 
      ReportDataSource datasource = new ReportDataSource("DataSet1", ie); 
      ReportViewer1.LocalReport.DataSources.Clear(); 
      ReportViewer1.LocalReport.DataSources.Add(datasource); 
     } 

    } 
} 

6.Build Ve Çalıştırın

İlgili konular