1
votes

I have data set with following columns 1. PRN 2. Name 3. Module name 4. Theory Marks 5. Total Marks this data set is field with different modules of same course and data is comes from database

I have given this data set data to crystal report as data source

I want to display TheoryMarks and totalMarks under ModuleName in below format

       ModuleName1              ModuleName2              ModuleName3

PRN Name Theory Marks TotalMarks Theory Marks TotalMarks

I have tried group column using Module Name .I have also tried CrossTab Expert but its not allowing me to add theory marks and total marks

string reportPath; string pathText = "PGCourseResultCrystalreport";

string path = "PGCourseResult.rpt";

if (pathText == "PGCourseResultCrystalreport")
{

    reportPath = Server.HtmlEncode(Request.PhysicalApplicationPath).ToString() + "MemberArea\\ResultReport\\" + path;
    rptDoc.Load(reportPath);
    error.Text += "reportdocloaded";
    //DataTable Resut = GetResultData();

    try
    {


        string query = "select P.PRN, P.[StudentName] ,P.TheoryMarks,L.TotalMarks,L.ModuleName from   [PGCoursesTheoryMarksMaster]  P,[ModulewiseLabInternalMarks] L  where L.PRN=P.PRN and P.Centre_ID=L.CentreId and P.Course_ID=L.Course_ID and P.Module_ID=L.Module_ID and P.Batch_ID=L.Batch_ID and P.Centre_ID=@centreId and P.Course_ID=@courseId   and P.Batch_ID=@batchId ";
        SqlConnection con = new SqlConnection(System.Configuration.ConfigurationManager.ConnectionStrings["aoldbConnectionString"].ConnectionString);

        string centreID = DDLCentreList.SelectedValue;
        //   string BatchID = BatchIdDropDown.SelectedValue;
        int  CourseId =  Convert.ToInt32( DropDownListCourse.SelectedValue);
        SqlCommand cmd = new SqlCommand(query, con);
        cmd.Parameters.AddWithValue("@CentreId", Convert.ToInt32(centreID));
        cmd.Parameters.AddWithValue("@courseId", CourseId);
        cmd.Parameters.AddWithValue("@batchId", batchId);
        if (con.State == ConnectionState.Open)
        {
            con.Close();
        }
        con.Open();
        using (SqlDataAdapter sda = new SqlDataAdapter(cmd))
        {
            sda.Fill(CourseMarks, "MainResultData");
            foreach (DataRow row in CourseMarks.Tables[0].Rows)
            {
                error.Text += row["PRN"].ToString();
            }

I want to display result as explained .

1

1 Answers

0
votes

CrossTab is the right approach. Let the CrossTab do the totals. In other words, instead of trying to select totals as the CrossTab values, select the detail data and let the CrossTab do the averaging, summing, etc.