Używam Visual Studio 2010. Pracowałem na Crystal Reporting wcześniej, ale teraz chcę generować raporty za pomocą Report Viewer. Ponieważ jestem nowy w tym temacie, poprowadź mnie. Dzięki !!!Jak utworzyć raport w asp.net za pomocą Report Viewer
Odpowiedz
podstawowy poradnik dla Ciebie
Adding and Configuring the ReportViewer Controls
Creating an ASP.NET report using Visual Studio 2010 - Part 1
Creating an ASP.NET report using Visual Studio 2010 - Part 2
Creating an ASP.NET report using Visual Studio 2010 - Part 3
How to use the Report Viewer Control to access a Reporting Services Server
Moje kod działa, aby utworzyć raport dla obiektów klasy biznes ...
Tworzenie raportu przy użyciu klasy Business Objects & ReportViewer (ASP.NET/ C#) 1.Create Student Class
public class StudentClass
{
public int No { get; set; }
public string Name { get; set; }
public string Degree { get; set; }
}
2.Create Studenta repozytorium z GetStudents() funkcja
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.Using Zgłoś Kreator tworzenia „StudentReport.rdlc” i wybierz DataSource
4.In Index.aspx dodać Script Manager i Report Viewer z ToolBox metodę
<div>
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
<rsweb:ReportViewer ID="ReportViewer1" runat="server">
</rsweb:ReportViewer>
</div>
5.Modify Page_Load() (przeciągnij i upuść) w kodzie za akt
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 I Uruchom
Dzięki Pranay ... Te podstawowe samouczki są dla mnie pełne pomocy ... –
@SonamMohite - zapraszamy ... czekam na awans w mojej odpowiedzi .. –
Hej Pranay ... Po pierwsze dzięki za pomoc . Po prostu istnieje małe zamieszanie związane z tworzeniem zestawu danych z zapisanymi procedurami. Jak dobrze działałem z DataSet z Table, więc teraz chcę wypróbować ten. Możesz umieścić kod dla tego. –